▪️Liquid Email

Liquid is an open-source template language designed to help you build dynamic, data-driven content, making it perfect for personalized and interactive emails. With Liquid, you can embed variables and conditionals directly into your HTML. This allows you to create highly customized emails that cater to individual recipients, leading to more engaging and effective campaigns.

How Does It Work?

  • Variables: Placeholders in the HTML that get replaced with actual data when the email is generated.

  • Conditionals: Control the content display based on specific criteria, making the email content adaptable to different scenarios.

To better understand the capabilities of Liquid lets follow a couple of examples.

Use of fallback

When greeting users, it's important to display their names. However, if some users haven't set up their names, you can use their username (or specific prefix like Mr, player, friend, etc.) as a fallback.

Hello, {{ state.user_first_name | default: state.core_username }}!

Set up name Result: Hello, Christopher! Not setup Result: Hello, christopher90!

Use of conditions & variables

Using conditions and variables in Liquid allows you to display personalized user information, significantly boosting user retention and giving the user a sense of exclusivity and personal attention.

For example, below, we are dynamically displaying the day of the week the email is sent, showing information of the last deposit, current balance amount, and showing countdown for promotion. At the same time, all that info is personalized for each recipient.

{% assign last_deposit_date = state.acc_last_deposit_date | date: "%s" %}
{% assign current_date = "now" | date: "%s" %}
{% assign time_difference = current_date | minus: last_deposit_date %}
{% assign days_since_deposit = time_difference | divided_by: 86400 %}

Happy {{ 'now' | date: "%A" }}! We miss you! You haven't done a deposit for
{% if days_since_deposit <= 7 %} {{ days_since_deposit }} days
{% elsif days_since_deposit <= 31 %} more than a week
{% else %} more than a month
{% endif %}
and your balance is
{% if state.acc_real_balance < 10 %}
really low at {{state.acc_real_balance | plus: 0}}.
{% else %}
{{state.acc_real_balance | plus: 0}}.
{% endif %}.
We have an exciting offer for you! If you deposit in the next {{'now' | date: "%H" | minus: 24 | abs}} hours and {{'now' | date: "%M" | minus: 59 | abs}} minutes , we will accumulate an additional 50% bonus to your deposited amount.

Example Result: Happy Friday! We miss you! You haven't made a deposit for 5 days, and your balance is really low at 3$. We have an exciting offer for you! If you deposit in the next 20 hours and 50 minutes , we will accumulate an additional 50% bonus to your deposited amount.

Example Result 2: Happy Saturday! We miss you! You haven't made a deposit for more than a month and your balance is at 20$. We have an exciting offer for you! If you deposit in the next 23 hours and 04 minutes , we will accumulate an additional 50% bonus to your deposited amount.

Set a specific timezone

Simply adjust the time to a specific timezone used by the email recipient so they don’t get confused by the system time, which is in UTC time. Here is a more detailed explanation: "now" | date: "%s" - gives us the current time of the Smartico system

current_time | plus: 7200 - is where we set the offset by seconds; plus/minus are used to determine if you want to offset ahead/behind, 7200 seconds = 2 hours

{% assign %} is used to create and store a value in a variable which you can manipulate or in this instance, use for calculation

{{ adjusted_time | date: "%Y-%m-%d %H:%M" }} - is what we print to the user, and we define the format %Y-%m-%d %H:%M (year, month, date, hour, minute)

Warning: beware that the values are case sensitive, for instance %M shows minutes and %m shows month

{% assign current_time = "now" | date: "%s" %}
{% assign adjusted_time = current_time | plus: 7200 %}
{{ adjusted_time | date: "%Y-%m-%d %H:%M" }}

Result: Christopher, our Amazing Jackpot has reached an astonishing 67000$. Hurry up and play for a chance to win it!

Set a specific translation

If we want to use dynamic tags like day/month but the recipients are from different countries and speak different languages we can assign specific translations:

{% assign days = {
  "FR": {"Monday": "Lundi", "Tuesday": "Mardi", "Wednesday": "Mercredi", "Thursday": "Jeudi", "Friday": "Vendredi", "Saturday": "Samedi", "Sunday": "Dimanche"},
  "ES": {"Monday": "Lunes", "Tuesday": "Martes", "Wednesday": "Miércoles", "Thursday": "Jueves", "Friday": "Viernes", "Saturday": "Sábado", "Sunday": "Domingo"}
} %}
{% assign current_day = "now" | date: "%A" %}
{% assign user_language = state.core_user_language %}
{% if days[user_language] %}
  {% assign translated_day = days[user_language][current_day] %}
{% else %}
  {% assign translated_day = current_day %}
{% endif %}
{{ translated_day }}!

Spanish user result for Friday: Viernes French user result for Friday: Vendredi

Reminders for missions, jackpots etc.

Boost user engagement by sending email reminders to users when they have progressed in missions but haven’t finished them yet to remind them and trigger user activation. Give users a nudge on the rising Jackpot and motivate them to play more.

Jackpot amount:

{{ state.user_first_name }}, our Amazing Jackpot has reached an astonishing {{state.jackpot_amount}}. Hurry up and play for a chance to win it!

Result: Christopher, our Amazing Jackpot has reached an astonishing 67000$. Hurry up and play for a chance to win it!

Missions in progress:

{{ state.user_first_name }}, do you know that your {{event.meta.image_url}} {{event.meta.name}} mission is still in progress? Finish it and you will get {{event.meta.reward}}!

Result: Christopher, do you know that your “Play 5 Mini-Games” mission is still in progress? Finish it and you will get 10 Free Spins!

URL Encoding and Decoding

URLs can be encoded and decoded directly within your email template using `url_encode` and `url_decode`.

{{ "example.com/questions/what-is-the-question?#Answer#1" | url_encode }}

Result: https://example.com/questions%3Fwhat-is-the-question%23Answer%231

Many more...

Check all Liquid supported filters and commands below:

Last updated

Was this helpful?