Skip to main content

Liquid Templating in Messages

Ira avatar
Written by Ira
Updated this week

Liquid templating in messages allows for greater flexibility in creating 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 a 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 the full list of objects available in Omnisend in the reference table below.

Tags (Automations only)

Tags are used to create the logic and control flow for templates. Square braces and percent signs denote tags: [% 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

Hi [[ contact.first_name ]], welcome to Omnisend!

Tip: This filter automatically adjusts the name to its vocative form in supported languages, making your messages sound more natural and personal. This can be achieved by using vocative personalization:


[[ contact.first_name | vocative ]]

Personalization with fallback

Hi [[ contact.first_name | default: 'there' ]], welcome to Omnisend!

Personalization with name capitalization

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.

Conditional Statements (Automations only)

Language localization

[% 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

[% 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

Omnisend © [[ current_date | date:'%Y' ]]

Objects' reference table

Group

Dropdown title

Tag

Value type

Description

Contact

Email

[[ contact.email ]]

string

Contact email

Contact

Name

[[ contact.first_name ]]

string

Contact's first name

Contact

Surname

[[ contact.last_name ]]

string

Contact's last name

Contact

City

[[ contact.city ]]

string

Contact's city

Contact

Country

[[ contact.country ]]

string

Contact's country

Contact

State

[[ contact.state ]]

string

Contact's state

Contact

Postal code

[[ contact.postal_code ]]

string

Contact's postal code

Contact

Unsubscribe link

[[ unsubscribe_link ]]

-

Contact's link to unsubscribe

Contact

Preference center link

[[ preference_link ]]

-

Contact preference link to apply changes

Contact

Custom properties

[[ contact.custom_properties.customPropertyName ]]

object

Contact's custom properties

Contact

Phone number

[[ contact.phone_number ]]

string

Contact's phone number

Account

Name

[[ account.name ]]

string

Account's name

Account

Address

[[ account.address ]]

string

Account's address

Account

City

[[ account.city ]]

string

Account's city

Account

ZIP / Postal code

[[ account.zipCode ]]

string

Account's ZIP / Postal code

Account

Country

[[ account.country ]]

string

Account's country

Account

Website URL

[[ account.website ]]

string

Account's website URL

Account

Time zone

[[ account.timezone ]]

string

Account's timezone

Account

Currency

[[ account.currency ]]

string

Account's currency

Date

Current day

[[ current_date | date:'%d' ]]

-

The day on which the action is performed

Date

Current day name

[[ current_date | date:'%A' ]]

-

The day on which the action is performed

Date

Current month

[[ current_date | date:'%m' ]]

-

The month when the action is performed

Date

Current month name

[[ current_date | date:'%B' ]]

-

The month name when the action is performed

Date

Current year

[[ current_date | date:'%Y' ]]

-

The current year when the action is performed

Order

Order ID

[[ order.order_id ]]

string

Order's ID

Order

Order number

[[ order.order_number ]]

int64

Order's number

Order

Order name

[[ order.order_name ]]

string

Order's name

Order

Order date

[[ order.order_date ]]

Date

Date when order is created

Order

Currency

[[ order.currency ]]

string

Order's currency

Order

Total price

[[ order.total_price ]]

int64

Order's sum in total

Order

Subtotal price

[[ order.subtotal_price ]]

int64

Subtotal order's sum

Order

Discount

[[ order.discount ]]

int64

Order's discount

Order

Shipping price

[[ order.shipping_price ]]

int64

Order's shipping price

Order

Order status page URL

[[ order.order_url ]]

string

URL to reach exact order information

Order

Order note

[[ order.note ]]

string

Additional order notes

Billing address

First name

[[ order.billing_address.first_name ]]

string

Contact's first name provided in billing address

Billing address

Last name

[[ order.billing_address.last_name ]]

string

Contact's last name provided in billing address

Billing address

Country

[[ order.billing_address.country ]]

string

Contact's country provided in billing address

Billing address

Country code

[[ order.billing_address.country_code ]]

string

Contact's country code provided in billing address

Billing address

State

[[ order.billing_address.state ]]

string

Contact's state provided in billing address

Billing address

State code

[[ order.billing_address.state_code ]]

string

Contact's state code provided in billing address

Billing address

City

[[ order.billing_address.city ]]

string

Contact's city provided in billing address

Billing address

Address 1

[[ order.billing_address.address1 ]]

string

Contact's address (1st line) provided in billing address

Billing address

Address 2

[[ order.billing_address.address2 ]]

string

Contact's address (2nd line) provided in billing address

Billing address

ZIP / Postal code

[[ order.billing_address.zip ]]

string

Contact's ZIP / Postal code provided in billing address

Billing address

Company

[[ order.billing_address.company ]]

string

Contact's company title provided in billing address

Billing address

Phone

[[ order.billing_address.phone ]]

string

Contact's phone number provided in billing address

Shipping address

First name

[[ order.shipping_address.first_name ]]

string

Contact's first name provided in shipping address

Shipping address

Last name

[[ order.shipping_address.last_name ]]

string

Contact's last name provided in shipping address

Shipping address

Country

[[ order.shipping_address.country ]]

string

Contact's country provided in shipping address

Shipping address

Country code

[[ order.shipping_address.country_code ]]

string

Contact's country code provided in shipping address

Shipping address

State

[[ order.shipping_address.state ]]

string

Contact's state provided in shipping address

Shipping address

State code

[[ order.shipping_address.state_code ]]

string

Contact's state code provided in shipping address

Shipping address

City

[[ order.shipping_address.city ]]

string

Contact's city provided in shipping address

Shipping address

Address 1

[[ order.shipping_address.address1 ]]

string

Contact's address (1st line) provided in shipping address

Shipping address

Address 2

[[ order.shipping_address.address2 ]]

string

Contact's address (2nd line) provided in shipping address

Shipping address

ZIP / Postal code

[[ order.shipping_address.zip ]]

string

Contact's ZIP / Postal code provided in shipping address

Shipping address

Company

[[ order.shipping_address.company ]]

string

Contact's company title provided in shipping address

Shipping address

Phone

[[ order.shipping_address.phone ]]

string

Contact's phone number provided in shipping address

Cart

Abandoned cart URL

[[ abandoned_cart.recover_url ]]

string

URL to reach/recover abandoned cart

Did this answer your question?