If you haven’t used the personalization tags, you should check the article about how can you personalize your emails with attributes and even create your own fields in your list. Now, you can also send emails in any language.

With MoonMail you can go even further in your email marketing strategy by personalizing the content depending on your subscribers' tags/fields. All with the power of Liquid Markup Language

First, we need to take into account the basics about the Operators and Content Tags:

Operators 

For logical and comparison rules.

  • == (equals)
  • != (does not equal)
  • > (greater than)
  • < (less than)
  • >= (greater than or equal to)
  • <= (less than or equal to)
  • or (logical or)
  • and ( logical and)

Content tags

Content tags create the logic and control the flow for the templates. They are denoted by curly braces and percent signs: {% and %}. There are many control flows that you can use:

if

Executes a block of code only if a certain condition is true.

input:

{% if product.title == 'Awesome Shoes' %}
  These shoes are awesome!
{% endif %}


Output:

These shoes are awesome!


unless

The opposite of if – executes a block of code only if a certain condition is not met.

Input:

{% unless product.title == 'Awesome Shoes' %}
  These shoes are not awesome.
{% endunless %}

Output:

Take advantage of the 50% discount! Apply the coupon: SUMMER50


elsif / else

Adds more conditions within an if or unless block.

Input:

<!-- If customer.name = 'anonymous' -->
{% if customer.name == 'kevin' %}
  Hey Kevin!
{% elsif customer.name == 'anonymous' %}
  Hey Anonymous!
{% else %}
  Hi Stranger!
{% endif %}


Output:
Hey Anonymous!


case/when

Creates a switch statement to compare a variable with different values. case initializes the switch statement, and when compares its values.

Input:
{% assign handle = 'cake' %}
{% case handle %}
  {% when 'cake' %}
     This is a cake
  {% when 'cookie' %}
     This is a cookie
  {% else %}
     This is not a cake nor a cookie
{% endcase %}


Output:
This is a cake


The markup used in content tags does not produce any visible text. This means that you can assign variables and create conditions and loops without showing any of the Liquid logic on the page.

Let’s try an example where you want to have dynamic content depending on the language or country of your subscribers.

For a list containing 2 subscribers, one in Spain and the other in the US and you want to send content in both English and Spanish in the same email so you can use an IF control.

If you go to the preview you’ll see the example with the information of the last subscriber, in this case, the preview is for a user from the US.

In this way, you can personalize your content with products, industry, country, or any other field that you create. Just make sure you have updated your subscribers' information. If "country" is empty no content would be delivered, in that case, it's safer to also add else at the end as a placeholder.

{% if country == 'Spain' %}
Hola

{% elsif country == 'US' %}
Hey 

{% else %}
Hi Stranger! 

{% endif %}

Did this answer your question?