What is Liquid?
Liquid is a template language that allows the loading of dynamic data into an element of an email or website. This coding language is used in many places, including Shopify, who originally created it.
Where Can It Be Used in Listrak?
Liquid can be used to build flash emails or create dynamic email subject lines. When creating emails you can use liquid in HTML or within the drag-and-drop email builder.
Dive deeper into the implementation of liquid coding:
The Elements of Liquid
If you are unfamiliar with Liquid Coding, the definitions below are going to be helpful when getting started.
What is an Object?
An object is a variable in liquid that can be used as part of the conditional logic to determine what version a contact should receive and can also be used as personalization in the subject line or message body.
đ Including an object in the message body or subject line with no additional logic will display the value stored in the field for the individual contact.
Hi {{contact.first_name}}
What is a Liquid Filter?
A filter in liquid is very different than a filter in Listrak's system. A liquid filter is used to modify the appearance of an object variable. For example, a liquid filter can capitalize a variable or transform the text so that is appears in all uppercase.
Hi {{contact.first_name | capitalize}}
What is a Tag?
A tag is used to control what a contact will and won't see when using objects and filters. A tag begins with {% and ends with %}. Any input between these two will not visually appear.
{% This information will not appear %} but this will!
What is Liquid's Logic?
Liquid allows the use of if/els logic to determine which version of content a contact would receive. The if/els logic can evaluate an object's value. For example, send different subject lines based on a contact's loyalty tier or change a contact's subject line if the last browsed category profile field contains a specific word. If/els logic can also be used to create dynamic content within the flash send email builder.
For example, the if/els logic could evaluate the variable of favorite season. In the table below you will see the value the statement is looking for and the result that would appear. In this example, an operator like equals can be used to specify the different seasons.
Value | Result |
Spring | Fresh looks to put a spring in your step. |
Summer | Cool looks to soak up this summer. |
Fall | Looks you'll fall for! |
Winter | Cozy looks to keep you warm all season long. |
Blank or value that is not specified above | Looks you'll be loving all year long. |
âď¸ If you do not use if/els logic in email dynamic content, all contacts will be evaluated to determine if they should see the content or if it should be hidden.
Understanding Liquid Logic
There are two main ways to employ liquid logic 1) create a single piece of content and use logic to determine if users should see the content or 2) create a cascade of logic with multiple pieces where users will see one of the pieces for which they are eligible.
âď¸ Option 1 is only available in email dynamic content, email subject lines must include a default to ensure the message will send.
Operators are key logic component that is used to determine what criteria needs to be found in the object in order for someone to receive the specified output.
đĄ Text values used in connection with these operators should be enclosed in quotation marks.
Operator | Syntax |
Equals | == |
Does Not Equal | != |
Greater Than | > |
Less Than | < |
Greater Than or Equal To | >= |
Less Than or Equal To | <= |
Or | or |
And | and |
Contains | contains |
It is also important to know what values to target with the operators. When using data such as checkbox and radio button data, the system will look for specific values based on if the values are selected.
đĄ The value will depend on the value used during the initial contact import. Export your contacts to see the specific values stored in their profile fields.
Data Type | Selected | Not Selected |
Radio Button | 1 TRUE on | 0 FALSE off |
Checkbox | on 1 TRUE | off 0 FALSE |
â ď¸ These values are stored as text and must be enclosed in quotation marks. Numbers stored as numerical values do not use quotation marks.
Below is an example of the dynamic subject line where both the dynamic and default options are included.
{% if contact.interestedinmore == "1" %}
Thank you for your interest! We will be in touch soon.
{% else %}
Come back any time to learn more!
{% endif %}In the example below, a contact may have one of multiple values in their field. The if statement will look for one of the three values listed here (1, on, or TRUE) and send the specified subject line if a contact has one of these values.
{% if contact.interestedinmore == "1" or contact.interestedinmore == "on" or contact.interestedinmore == "TRUE" %}
Thank you for your interest! We will be in touch soon.
{% else %}
Come back any time to learn more!
{% endif %}Creating an If/Els Statement
An If/Els statement allows you to specify multiple potential dynamic options where a user will see the first option where they meet the criteria. Contacts who do not meet any of the criteria will receive the content that appears after the else statement.
An If/Els statement can be applied to create a dynamic subject line or applied to rows of message content to create cascading dynamic content.
The example below displays different email subject lines to loyalty members based on their current loyalty tiers.
{% if contact.loyalty_tier == "Bronze" %}
Bronze VIP members earn 2x the points during our VIP sale.
{% elsif contact.loyalty_tier == "Silver" %}
Silver VIP members earn 3x the points during our VIP sale.
{% elsif contact.loyalty_tier] == "Gold" %}
Gold VIP members earn 4x the points during our VIP sale.
{% else %}
Become a VIP to make the most of your points!
{% endif %}Filtering in Liquid
Filtering in Liquid provides a way to change the way an object appears. Common types of filters include: show the whole output in uppercase, capitalize the first letter, add a specific value to the beginning, or adding a specific value to the end. Filters are often used when the object appears in the subject line. Below you will find a few examples of common filters.
Append a pipe and the specific action that should be taken after the field name to add a filter to the object.
đ Placing a filtered object in the message body or subject line will display the value stored in the field for each contact with the applied filter.
Capitalize:
{{contact.first_name | capitalize}}
Uppercase:
{{contact.first_name | upcase}}
Downcase/Lowercase:
{{contact.first_name | downcase}}
Providing a Fallback if Not Value is Provided
{{ contact.first_name | default: "there" }}
Learn more about filters available in Liquid.