Common Mistakes with the Liquid Templating Language

Amplemarket Team
Amplemarket Team
  • Updated

 

Amplemarket enables you to hyper personalize your email templates with the liquid templating language. You might run into an error when trying to send out a template due to a syntax error in the template. This article compiles the most common mistakes and how to resolve them.

 

Dynamic Fields

When you are using dynamic fields (example - {{first_name}}) you should:

  • Always use {{ }} two curly brackets at the beginning and at the end.

  • Make sure that there is no space between the curly brackets this would produce an error:
    {❌{first_name}}
  • Verify the syntax of the column header between the brackets. Example: {{FIRSTNAME}} would give an error and should be {{first_name}}.

Statements

Be careful with the syntax when creating "if" statements in your liquid email templates. The right framework for a statement is:

{% if CONDITION %}
{% elsif OTHER_CONDITION %}
{% else %}
{% endif %}

 

Syntax

In a statement, you only insert the “if” or “case” at the beginning of the statement.

 

{% if title contains “CEO” or title contains “Founder” %}

 

❌  {% if title contains “CEO” or if title contains “Founder” %}

 

Endif / Endcase

Make sure every statement is closed.

 

{% if CONDITION %}

{% endif %} 👈

 

{% case CONDITION %}

{% endcase %} 👈

 

If / Elsif

In an "if" statement, make sure that only the opening statement starts with “if”. The remaining statements should contain “elsif”.

 

{% if CONDITION %}
{% elsif OTHER_CONDITION %}🏆
{% elsif OTHER_CONDITION %}🏆
{% else %}
{% endif %}
{% if CONDITION %}
{% if OTHER_CONDITION %} 👎
{% if OTHER_CONDITION %} 👎
{% else %}
{% endif %}

 

Hierarchy of statements - from specific to more generic

It is also important to understand the hierarchy of these statements. Amplemarket will first check if the first condition is fulfilled. If it is, Amplemarket will not check for the following options and go to the next part of the message.

Let us take a look at the example below. We would like to target a “Sales Enablement Manager”. In the example below you can see there is a specific message crafted for that title (3rd statement). However, he will receive the message included in the first statement as his title also contains “Sales”.

Amplemarket will stop searching for the conditions after it understands the first condition is fulfilled and not verify the other statements. Therefore, make sure that you order the statements from “specific” to “generic”.

 

{% if title contains “Vice President of Sales” %}
{% elsif title contains “Sales Enablement Manager” %}
{% elsif title contains “Sales” %} 👈
{% else %}
{% endif %}
{% if title contains “Sales” %} 👈
{% elsif title contains “Vice President of Sales” %}
{% elsif title contains “Sales Enablement Manager” %}
{% else %}
{% endif %}

 

Empty “else” statement

Sometimes you might not receive an error message but an empty preview of a template. That likely means that your statement lacks an “{% else %}” statement. If none of the statements is fulfilled the “{% else %}” will serve as a fallback. If the fallback is not present, Amplemarket will not fill in anything and you will see an empty part of the email.

 

{% if title contains “Sales” %}
Happy to connect with people in the sales industry!
{% else %}
🤷‍♂️ ❌
{% endif %}

 

This can, however, be useful. For example, if you want to personalize your messages to some people but not for others. 

{% if personalized_message %}
{{personalized_message}}
{% endif %}

 

The importance of case

Prospects location: Germany

Prospects location: Germany

{% case country %}
{% when ✅ 'Germany' %}
Vielen Dank!
{% when 'Spain' %}
Gracias!
{% else %}
Thanks!
{% endcase %}
{% case country %}
{% when ❌ 👉 'germany' %}
Vielen Dank!
{% when 'spain' %}
Gracias!
{% else %}
Thanks!
{% endcase %}

 

Liquid Syntax Library

In case you have any other ideas you would like to test, feel free to consult the liquid syntax library. All the possibilities described in the library can be applied in the Amplemarket text editor as well.

 

Liquid Syntax Library

 

 

 

Was this article helpful?

0 out of 0 found this helpful

Have more questions? Submit a request