Guides

Liquid Templating in Messages


Liquid templating in messages allows for greater flexibility to create dynamic and powerful messages for your customers. You can use Liquid syntax to manage content in emails, text messages (SMS/MMS) and push notifications.

Basics

Liquid is an open source templating language created by Shopify. The official documentation can be found here. Liquid code has three elements: objects, tags and filters. Omnisend uses Liquid syntax with simple difference - double square braces [[ ]] instead of double curly braces {{ }} and [% %] braces instead of {% %}. [[ contact.email ]]

Objects

Objects are variable names. Liquid objects contain attributes to output dynamic content in your message. For example, you can use variables stored in your contact profiles. Objects are always enclosed within double square braces. [[ contact.first_name ]]
All objects available in Omnisend are grouped into themes based on data type. Major themes are contact’s (subscriber’s) properties (name structured as [[ contact.variable ]] and account properties (name structured as [[ account.variable ]] as well as order properties (name structured as [[ order.variable ]]) and cart properties (name structured as [[ cart.variable ]]) for automation workflows.

View full list of objects available in Omnisend in a reference table below.

Tags (Automations only)

Tags are used to create the logic and control flow for templates. Tags are denoted by square braces and percent signs: [% and %]. They produce no visible text. [% if contact.first_name %]
Hi [[ contact.first_name ]]
[% endif %]

View all Liquid tags here.

Filters

Filters are used to change the output of a Liquid object. Filters are used within an output (in curly braces) and are separated by a | (pipe). [[ 'mywebsite.com/orders/' | append: order.order_id ]]
View all Liquid filters here.

Common Use-Cases

Here are several helpful common use-cases for Liquid syntax:

Personalization

Personalization: The most common personalization scenario is to pull in fields like a person’s name, their city, etc. This works similarly across message types. Hi [[ contact.first_name ]], welcome to Omnisend!
Personalization with fallback: Now, what if you didn’t always have the variable [[ contact.first_name ]] for every one of your subscribers. You can specify a default value to be used if you don’t have the person’s name. Hi [[ contact.first_name | default: 'there' ]], welcome to Omnisend!
Personalization with name capitalization: Sometimes, you may have collected names without capitalizing them. This is an easy fix too. You can just use the special capitalize keyword. If the user’s first name is stored as “jon”, this will read “Hi Jon, welcome to Omnisend!” Hi [[ contact.first_name | capitalize | default: 'there' ]], welcome to Omnisend!
Variable insertion: Variable insertion can be used in many different parts of various messages. You can insert order data or order sum in different places of the message body. See full list of available variables (objects).

Conditional Statements (Automations only)

Language localization: Create a single message with different text for each language, rather than creating separate messages for each. [% if contact.custom_properties.language == 'Spanish' %]
Hola [[ contact.first_name ]]!
[% elsif contact.custom_properties.language == 'French' %]
Bonjour [[ contact.first_name ]]!
[% else %]
Hi [[ contact.first_name ]]!
[% endif %]

Content recommendations: Send recommendations based on properties you already have about the subscriber. [% if contact.country == 'UK' or contact.country == 'Ireland' %]
Have you visited our newest flagship store in London?
[% endif %]

Formatting

User name capitalization: Hi [[ contact.first_name | capitalize ]]
Appending custom text: [% assign campaign_destination = '/landing_page.html' %]
[[ account.website | append: campaign_destination ]]

Time formatting: Pass the special object 'now' to get the current time and use that in your messages to automatically update copyrights as the year changes. Omnisend © [[ current_date | date:'%Y' ]]

Objects' reference table

Group
Dropdown title
Tag
Value type
Description
Contact
Email
[[ contact.email ]]
string
Contact email
Name
[[ contact.first_name ]]
string
Contact's first name
Surname
[[ contact.last_name ]]
string
Contact's last name
City
[[ contact.city ]]
string
Contact's city
Country
[[ contact.country ]]
string
Contact's country
State
[[ contact.state ]]
string
Contact's state
Postal code
[[ contact.postal_code ]]
string
Contact's postal code
Unsubscribe link
[[ unsubscribe_link ]]
-
Contact's link to unsubscribe
Preference center link
[[ preference_link ]]
-
Contact preference link to apply changes
Custom properties
[[ contact.custom_properties.customPropertyName ]]
object
Contact's custom properties
Phone number
[[ contact.phone_number ]]
string
Contact's phone number
Group
Dropdown title
Tag
Value type
Description
Account
Name
[[ account.name ]]
string
Account's name
Address
[[ account.address ]]
string
Account's address
City
[[ account.city ]]
string
Account's city
ZIP / Postal code
[[ account.zipCode ]]
string
Account's ZIP / Postal code
Country
[[ account.country ]]
string
Account's country
Website URL
[[ account.website ]]
string
Account's website URL
Time zone
[[ account.timezone ]]
string
Account's timezone
Currency
[[ account.currency ]]
string
Account's currency
Group
Dropdown title
Tag
Value type
Description
Date
Current day
[[ current_date | date:'%d' ]]
-
The day name when action is performed
Current day name
[[ current_date | date:'%A' ]]
-
The day name when action is performed
Current month
[[ current_date | date:'%m' ]]
-
The month when action is performed
Current month name
[[ current_date | date:'%B' ]]
-
The month name when action is performed
Current year
[[ current_date | date:'%Y' ]]
-
The current year when action is performed
Group
Dropdown title
Tag
Value type
Description
Order
Order ID
[[ order.order_id ]]
string
Order's ID
Order number
[[ order.order_number ]]
int64
Order's number
Order name
[[ order.order_name ]]
string
Order's name
Order date
[[ order.order_date ]]
Date
Date when order is created
Currency
[[ order.currency ]]
string
Order's currency
Total price
[[ order.total_price ]]
int64
Order's sum in total
Subtotal price
[[ order.subtotal_price ]]
int64
Subtotal order's sum
Discount
[[ order.discount ]]
int64
Order's discount
Shipping price
[[ order.shipping_price ]]
int64
Order's shipping price
Order status page URL
[[ order.order_url ]]
string
URL to reach exact order information
Order note
[[ order.note ]]
string
Additional order notes
Group
Dropdown title
Tag
Value type
Description
Billing address
First name
[[ order.billing_address.first_name ]]
string
Contact's first name provided in billing address
Last name
[[ order.billing_address.last_name ]]
string
Contact's last name provided in billing address
Country
[[ order.billing_address.country ]]
string
Contact's country provided in billing address
Country code
[[ order.billing_address.country_code ]]
string
Contact's country code provided in billing address
State
[[ order.billing_address.state ]]
string
Contact's state provided in billing address
State code
[[ order.billing_address.state_code ]]
string
Contact's state code provided in billing address
City
[[ order.billing_address.city ]]
string
Contact's city provided in billing address
Address 1
[[ order.billing_address.address1 ]]
string
Contact's address (1st line) provided in billing address
Address 2
[[ order.billing_address.address2 ]]
string
Contact's address (2nd line) provided in billing address
ZIP / Postal code
[[ order.billing_address.zip ]]
string
Contact's ZIP / Postal code provided in billing address
Company
[[ order.billing_address.company ]]
string
Contact's company title provided in billing address
Phone
[[ order.billing_address.phone ]]
string
Contact's phone number provided in billing address
Group
Dropdown title
Tag
Value type
Description
Shipping address
First name
[[ order.shipping_address.first_name ]]
string
Contact's first name provided in shipping address
Last name
[[ order.shipping_address.last_name ]]
string
Contact's last name provided in shipping address
Country
[[ order.shipping_address.country ]]
string
Contact's country provided in shipping address
Country code
[[ order.shipping_address.country_code ]]
string
Contact's country code provided in shipping address
State
[[ order.shipping_address.state ]]
string
Contact's state provided in shipping address
State code
[[ order.shipping_address.state_code ]]
string
Contact's state code provided in shipping address
City
[[ order.shipping_address.city ]]
string
Contact's city provided in shipping address
Address 1
[[ order.shipping_address.address1 ]]
string
Contact's address (1st line) provided in shipping address
Address 2
[[ order.shipping_address.address2 ]]
string
Contact's address (2nd line) provided in shipping address
ZIP / Postal code
[[ order.shipping_address.zip ]]
string
Contact's ZIP / Postal code provided in shipping address
Company
[[ order.shipping_address.company ]]
string
Contact's company title provided in shipping address
Phone
[[ order.shipping_address.phone ]]
string
Contact's phone number provided in shipping address
Group
Dropdown title
Tag
Value type
Description
Cart
Abandoned cart URL
[[ abandoned_cart.recover_url ]]
string
URL to reach/recover abandoned cart