Using Liquid

Liquid is a templating language that enables you to customize messages using your audience's data. You can integrate liquid into any aspect of your message, extending beyond personalized message content. This flexibility lets you personalize sender information, email subjects, survey interactions, and more.

How it works

Liquid empowers you to incorporate variables and logical statements within your messages, drawing from sources such as Contact Attributes, Event data, and more. When we transmit a message, we analyze the liquid syntax within your messages to create a personalized message tailored to the individual recipient.

For instance, if you've stored an individual's first name as an attribute labeled "firstname", you can access their name as {{contact.firstname}}. Consequently, each time you send that message to an individual, we'll integrate their first name into the message.

When a person lacks the "firstname" attribute —If a default value is not provided and the field is missing or not set on the user, the field will be blank in the message.

📘

Note

If a particular value for a merge tag cannot be found by Liquid or you have perhaps mistyped the tag object and value, Liquid will output nothing.

We strongly encourage you to populate the default field option when inserting the merge tag (or manually type in the | default: filter) whenever possible in places where you are not certain that the merge tag will have the value. Learn more about [default](If a particular value for a merge tag cannot be found by Liquid or you have perhaps mistyped the tag object and value, Liquid will output nothing.).

Whitespace control

In Liquid, you can include a hyphen in your tag syntax {{-, -}}, {%-, and -%} to strip whitespace from the left or right side of a rendered tag.

Normally, even if it doesn’t print text, any line of Liquid in your template will still print a blank line in your rendered HTML:

{% assign my_variable = "tomato" %}  
{{ my_variable }}

Notice the blank line before “tomato” in the rendered template:


tomato

By including a hyphen in your assign closing delimiter, you can strip the whitespace following it from the rendered template:

{% assign my_variable = "tomato" -%}  
{{ my_variable }}
tomato

👍

Always test the rendering of your liquid syntax before pushing message to a wider audience.