Liquid is a templating language created by Shopify. You can take advantage of Liquid syntax to format and personalize at scale. Below we will provide some examples flows you can use in your email and reply sequence templates.
Formatting and Statements
Formatting
The liquid syntax allows you to easily format dynamic fields.
Hello #{{first_name}}!
Hello John!
Hello #{{first_name | upcase}}!
Hello JOHN!
Hello #{{first_name | downcase}}!
Hello john!
If/Else Statement
Thanks to the liquid syntax you can apply logic to your template. You can use tags to execute if/else
statements to accommodate multiple use cases with one single template.
A typical if/else
statement can be written as:
{% if CONDITION %}
{% elsif OTHER_CONDITION %}
{% endif %}
For example:
{% if first_name %}
Hi #{{first_name}},
{% else %}
Hello,
{% endif %}
Would return:
Hi John,
if first_name is an available dynamic field. If first_name is not available then it would produce:
Hello,
Case Statement
If you need more conditions then an if/else
statement might not be the best option. In that case you can use the case
statement. A typical case
statement can be written as:
{% case CONDITION %}
{% when CONDITION_1 %}
{% when CONDITION_2 %}
{% when CONDITION_3 %}
{% else %}
{% endcase %}
For example:
{% case country %}
{% when 'France' %}
Bonjour #{{first_name}},
{% when 'Spain' %}
Hola #{{first_name}},
{% else %}
Hi #{{first_name}},
{% endcase %}
Would return:
Bonjour John,
if John's in France, or
Hola John,
if John is in Spain, or
Hi John,
for any other country.
Assigning Random Numbers
Using this form of liquid syntax will increase the variability of your sequences and therefore your deliverability. In this case, your leads will receive slightly different emails based on a random number generator.
{% assign randomNumber = first_name | size | modulo: 3 | plus: 1 %}
{% if randomNumber == 1 %}
{% elsif randomNumber == 2 %}
{% else %}
{% endif %}
In this case, the term "modulo" refers to the total amount of options that will be randomly assigned to a lead. You can choose to implement more of less than three options by altering this number. The "plus: 1", refers to the final 'else' statement, do NOT alter this number, it will cause issues when sending out your sequence.
Example:
{% assign randomNumber = first_name | size | modulo: 3 | plus: 1 %}
{% if randomNumber == 1 %}
Would you have time for a quick call?
{% elsif randomNumber == 2 %}
What do you think?
{% else %}
Does this sound interesting to you?
{% endif %}
Would return either:
I would love to set up a meeting, would you have time for a quick call?
If option 1, or
I would love to set up a meeting, what do you think?
if option 2, or
I would love to set up a meeting, does this sound interesting to you?
if option 3.
Practical examples for your emails
Customize your value propositions depending on job title:
{% if title contains "VP" or title contains "Vice President" %}
This is the value proposition for VPs.
{% elsif title contains "Director" %}
This is the value proposition for Directors
{% elsif title contains "Manager" %}
This is the value proposition for Managers
{% else %}
This is the value proposition for all other titles.
{% endif %}
Customize your greetings depending on your prospect's location:
{% case country %}
{% when 'France' %}
Merci!
{% when 'Germany' %}
Vielen Dank!
{% when 'Spain' %}
Gracias!
{% else %}
Thanks!
{% endcase %}
Multiple if's & elsif's:
{% if industry contains 'Accounting' or industry contains 'Banking' %}
Value proposition for Accounting & Banking.
{% elsif industry contains 'Retail' or industry contains 'Sporting Goods' %}
Value proposition for Retail & Sporting Goods.
{% elsif industry contains 'Restaurants' or industry contains 'Hospitality' %}
Value proposition for Restaurants & Hospitality.
{% else %}
All other industries value proposition.
{% endif %}
Customize your greetings depending on your prospect's location:
{% case country %}
{% when 'France' %}
Merci!
{% when 'Germany' %}
Vielen Dank!
{% when 'Spain' %}
Gracias!
{% else %}
Thanks!
{% endcase %}
Common mistakes
Syntax and spacing
Be careful with the syntax when creating statements in your liquid email templates. The right way to create statements is:
{% if CONDITION %}
...
if you write
{ % if CONDITION % }
...
it will produce an error. The same goes for:
{%if CONDITION%}
...
Always write {%
and %}
with the appropriate spacing.
Remember to close your if/else blocks and case statements.
Always remember to close your if/else
and case
statements otherwise it will make the Liquid render crash. So remember to always add an {% endif %}
every time you create a an {% if CONDITION %}
. The same goes for the case statements, always add {% endcase %}
every time you create {% case CONDITION %}
.
Use a plain text editor
Alway use a plaint text editor or write your templates on the Amplemarket text editor. If you use Microsoft Word or Google Docs "invisible" formatting will be added to your email templates and will make Liquid to crash.
Further reading
- For examples of all Amplemarket's Liquid Syntax instances and what they mean, please visit the article "Amplemarket"s Liquid Syntax Instances".
- Liquid, safe, customer-facing template language for flexible web apps: https://shopify.github.io/liquid/
- Liquid for Designers: https://github.com/Shopify/liquid/wiki/Liquid-for-Designers
If you have any other questions regarding Liquid Syntax, please reach out to Support@Amplemarket.com