fbpx
Email Marketing

A Beginner’s Guide to Liquid: Personalization And Dynamic Content in Braze

The significance of personalization is not lost on marketers anymore. 

As a result, business software vendors are enhancing their tools to make implementing personalization more intuitive. 

So the question now isn’t whether personalization is part of your client’s marketing strategy. It most certainly is. 

Rather, do you as a service provider have extensive software expertise? Can you implement personalization on your client’s preferred software or ESP? 

Because software literacy is how you’re going to stand out. 

At Email Uplers, we’re experts at 50+ ESPs, including Braze. All-round software literacy enables us to meet various ESP-specific project requirements to spec. 

In this beginner-friendly guide, Braze is where it’s at. We’re going to show you how to do personalization in Braze using Liquid, a programming language. 

What Is Liquid?

Components of Liquid

Objects in Liquid

Filters in Liquid

Tags in Liquid

Advanced Data Types: Arrays & Objects

Arrays of Objects

Practical Use Cases of Liquid

What Is Liquid? 

Liquid, developed by Shopify, is a programming language written in Ruby, which is used to create dynamic content based on user data. 

Liquid is open-source, meaning it’s available for use by anyone. Compared to more complex coding languages, Liquid is straightforward and easy to learn, making it an excellent tool for marketers looking to personalize their communications.

Key Points:

  • Origins: Developed by Shopify and adopted by customer engagement platforms like Braze
  • Usage: Powers dynamic content in emails, notifications, and more
  • Accessibility: Simple enough for marketers to learn with practice

If you choose to use Liquid in your email messages, be sure to insert it using the HTML editor as opposed to the classic editor.

— Braze

Components of Liquid

Liquid is composed of three main elements, each serving a specific role in creating dynamic content: variables, tags, and filters. 

1. Variables

  • Definition: Variables are placeholders that store data or values
  • Syntax: {{ variable_name }}
  • Functionality: Displays dynamic content, such as a customer’s name or order details.
  • Example: {{ first_name }} displays the customer’s first name.
  • Use Case: Personalize an email greeting with the recipient’s first name: Hello, {{ first_name }}!

2. Tags

  • Definition: Tags control the flow and structure of the template.
  • Syntax: {% tag %}
  • Functionality: Handles logic, loops, and conditions.
  • Example: {% if customer.is_vip %} initiates a conditional block.
  • Use Case: Display a special offer for VIP customers: {% if customer.is_vip %} Exclusive offer just for you! {% endif %}

3. Filters

  • Definition: Filters modify the output of a variable.
  • Syntax: {{ variable | filter }}
  • Functionality: Formats and manipulates data.
  • Example: {{ product.price | currency }} formats the price as currency.
  • Use Case: Format a product’s price to include a currency symbol: {{ product.price | currency }}

In our next section, we’ll explore these basics in a bit more detail.

Objects in Liquid 

Objects represent data points stored in Braze, accessed using standard attributes like {{ first_name }} and {{ email_address }}.

  • Example: {{ first_name }} inserts the recipient’s first name into the email.
  • Use Case: Include a user’s email address in a confirmation message: Your email address is {{ email_address }}

Filters in Liquid

Filters modify content within objects. Examples include:

  • {{ first_name | capitalize }}: Capitalizes the first letter of the first name.
  • {{ first_name | default: 'not here right now' }}: Uses default text if the first name is empty.
  • Use Case: Ensure the first name is always capitalized: Hello, {{ first_name | capitalize }}!

Tags in Liquid

Tags define conditional logic using if, else if, and else statements:

  • {% if first_name %}{{ first_name | capitalize }}{% endif %}: Prints the capitalized first name if it exists.
  • {% if first_name == 'Peter' %}Here is your update{% else %}Hi there{% endif %}: Personalized message based on the name.
  • Use Case: Provide a different message based on the user’s first name: {% if first_name == 'Peter' %} Hello, Peter! {% else %} Hello! {% endif %}

Place Liquid code within the <body> tag only. Placing it outside this tag may cause inconsistent rendering upon delivery.

— Braze

Advanced Data Types: Arrays & Objects

1. Arrays

  • Definition: Lists of items of the same data type.
  • Example: A user’s favorite sports: [“basketball”, “soccer”, “tennis”]
  • Use Case: Display a list of a user’s favorite sports: {% for sport in favorite_sports %} {{ sport }} {% endfor %}

2. Objects

  • Definition: Groups of metadata describing parent data.
  • Example: An item with properties like name, price, and category: {“name”: “T-shirt”, “price”: “20”, “category”: “clothing”}
  • Use Case: Display a product’s details: Product: {{ product.name }} – Price: {{ product.price }} – Category: {{ product.category }}

Arrays of Objects 

  • Definition: Lists of objects.
  • Example: A shopping cart with multiple items, each with properties like name, price, and size: [{“name”: “T-shirt”, “price”: “20”, “size”: “M”}, {“name”: “Jeans”, “price”: “40”, “size”: “L”}]
  • Use Case: Display items in a user’s shopping cart: {% for item in cart %} {{ item.name }} – {{ item.price }} – {{ item.size }} {% endfor %}

Practical Use Cases of Liquid

1. Content Personalization

  • Basic Personalization: Insert the user’s first name or other attributes.
    • Example: Hello, {{ first_name }}!
  • Advanced Use Cases: Customize content based on user behavior or preferences.
    • Example: Show different messages based on the user’s subscription status: {% if user.is_subscribed %} Thanks for being a subscriber! {% else %} Subscribe now for more updates! {% endif %}

2. Multilingual Emails

Create emails that adapt to the recipient’s language preference using Liquid’s conditional logic:

  • Data Preparation: Import user data with language preferences.
    • Example: Use a CSV file with language preferences: id,first_name,last_name,email,language
  • Email Setup: Use Liquid to dynamically adjust content based on language attributes.
    • Example: {% if language == ‘en’ %} Hello! {% elsif language == ‘es’ %} ¡Hola! {% endif %}

3. Abandoned Cart Emails

Leverage Liquid for loops to create dynamic abandoned cart emails:

  • Data Structure: Store cart items in a custom attribute.
    • Example: {“items_in_cart”: [{“id”: “123”, “name”: “T-shirt”, “price”: “20”}, {“id”: “456”, “name”: “Jeans”, “price”: “40”}]}
  • Loop through Items: Use loops to display each item in the email.
    • Example: {% for item in items_in_cart %} {{ item.name }} – {{ item.price }} {% endfor %}

4. Random Number Generation

Use current time and modulo operations to generate random numbers for various scenarios, like randomizing email subject lines:

  • Example: {% assign random_number = ‘now’ | date: ‘%N’ | modulo: 5 %} {% if random_number == 0 %} Subject Line 0 {% elsif random_number == 1 %} Subject Line 1 {% elsif random_number == 2 %} Subject Line 2 {% elsif random_number == 3 %} Subject Line 3 {% elsif random_number == 4 %} Subject Line 4 {% endif %}

Braze does not currently support 100% of Shopify’s Liquid… We highly recommend testing all messages using Liquid before sending them…

— Braze

Need A Hand to Get Started?

Liquid provides a powerful yet accessible way to create personalized and dynamic content in Braze. By understanding and leveraging variables, tags, and filters, marketers can enhance their campaigns and deliver more relevant messages to their audience. 

If you need help getting started, get in touch with our Braze-certified experts. For more information on this ESP, catch our series on all things Braze.

The post A Beginner’s Guide to Liquid: Personalization And Dynamic Content in Braze appeared first on Email Uplers.

August 6, 2024

Original Source https://email.uplers.com/blog/guide-using-liquid-dynamic-content-braze/

Related Articles

Back to top button
Close
Close