Operators
Liquid supports many operators that can be used in your conditional statements. This page covers the operators that Liquid supports and provides use cases of how you can use them in your messages.
This table lists the operators that are supported. Note that parentheses are invalid characters in Liquid and prevents your tags from working.
Syntax |
Operator Description |
== |
equals |
!= |
does not equal |
> |
greater than |
< |
less than |
>= |
greater than or equal to |
<= |
less than or equal to |
or |
condition A or condition B |
and |
condition A and condition B |
contains |
checks to see if a string or string array contains a string |
Tutorials
Let’s go through a few tutorials to learn how to use these operators for your marketing campaigns:
Choose message with an integer custom attribute
Let’s send push notifications with personalized promotional discounts to users who have or haven’t made purchases. The push notification will use an integer custom attribute called total_spend
to check a user’s total spend.
- Write a conditional statement using the greater than (
>
) operator to check if a user’s total spend is greater than 0
, indicating they’ve made a purchase. Then, create a message to send to those users.
1
2
| {% if {{custom_attribute.${total_spend}}} >0 %}
Surprise! We added a 15% discount code to your account that automatically applies to your next order.
|
- Add the
{% else %}
tag to capture users whose total spend equals 0
or doesn’t exist. Then, create a message to send to those users.
1
2
| {% else %}
Need a sign to update your wardrobe? We added a 15% discount code to your account that will automatically apply to your first order.
|
- Close the conditional logic with the
{% endif %}
tag.

Full Liquid code
1
2
3
4
5
| {% if {{custom_attribute.${total_spend}}} >0 %}
Surprise! We added a 15% discount code to your account that automatically applies to your next order.
{% else %}
Need a sign to update your wardrobe? We added a 15% discount code to your account that will automatically apply to your first order.
{% endif %}
|
Now if a user’s “Total Spend” custom attribute is greater than 0
, they will get the message:
1
| Surprise! We added a 15% discount code to your account that automatically applies to your next order.
|
If a user’s “Total Spend” custom attribute does not exist or is equal to 0
, they will get the following message:
1
| Need a sign to update your wardrobe? We added a 15% discount code to your account that will automatically apply to your first order.
|
Choose message with a string custom attribute
Let’s send push notifications to users, and personalize the message based on each user’s most recently played game. This will use a string custom attribute called recent_game
to check which game a user has last played.
- Write a conditional statement using the equals (
==
) operator to check if a user’s most recent game is Awkward Dinner Party. Then, create a message to send to those users.
1
2
| {% if {{custom_attribute.${recent_game}}} == 'Awkward Dinner Party' %}
You are formally invited to our next dinner party. Log on next week for another round of delectable dishes and curious conversations.
|
- Use the
elsif
tag with the equals (==
) operator to check if user’s most recent game is Proxy War 3: War of Thirst. Then, create a message to send to those users.
1
2
| {% elsif {{custom_attribute.${recent_game}}} == 'Proxy War 3: War of Thirst' %}
Your fleet awaits your next orders. Log on when you're ready to rejoin the war for hydration.
|
- Use the
elsif
tag with the does not equal (!=
) and “and” (&&
) operators to check if the user has a recent game (meaning the value isn’t blank), and that the game isn’t Awkward Dinner Party or Proxy War 3: War of Thirst. Then, create a message to send to those users.
1
2
| {% elsif {{custom_attribute.${recent_game}}} != blank && 'Awkward Dinner Party' or 'Proxy War 3: War of Thirst' %}
Limited Time Deal! Get 15% off our best-selling classics!
|
- Add the
{% else %}
tag to capture users who don’t have a recent game. Then, create a message to send to those users.
1
2
| {% else %}
Hey! I've got a deal for you. Buy 2 of our newest releases and get 10% off!
|
- Close the conditional logic with the
{% endif %}
tag.
Full Liquid code
1
2
3
4
5
6
7
8
9
| {% if {{custom_attribute.${recent_game}}} == 'Awkward Dinner Party' %}
You are formally invited to our next dinner party. Log on next week for another round of delectable dishes and curious conversations.
{% elsif {{custom_attribute.${recent_game}}} == 'Proxy War 3: War of Thirst' %}
Your fleet awaits your next orders. Log on when you're ready to rejoin the war for hydration.
{% elsif {{custom_attribute.${recent_game}}} != blank && 'Awkward Dinner Party' or 'Proxy War 3: War of Thirst' %}
Limited Time Deal! Get 15% off our best-selling classics!
{% else %}
Hey! I've got a deal for you. Buy 2 of our newest releases and get 10% off!
{% endif %}
|

Now, if a user last played Awkward Dinner Party, they’ll receive this message:
1
| You are formally invited to our next dinner party. Log on next week for another round of delectable dishes and curious conversations.
|
If a user’s most recent game is Proxy War 3: War of Thirst, they will receive this message:
1
| Your fleet awaits your next orders. Log on when you're ready to rejoin the war for hydration.
|
If a user has recently played a game that wasn’t Awkward Dinner Party or Proxy War 3: War of Thirst, they’ll get this message:
1
| Limited Time Deal! Get 15% off our best-selling classics!
|
If a user hasn’t played any games or that custom attribute doesn’t exist on their profile, they’ll get this message:
1
| Hey! I've got a deal for you. Buy 2 of our newest releases and get 10% off!
|
Abort message based on location
You can abort a message based on just about anything. Let’s abort a message if a user isn’t based in a specified area, as they might not qualify for the promotion, show, or delivery.
- Write a conditional statement using the equals (
==
) operator to check if the user’s time zone is America/Los_Angeles
, then create a message to send to those users.
1
2
| {% if {{${time_zone}}} == 'America/Los_Angeles' %}
Stream now!
|
- To avoid sending messages to users outside the
America/Los_Angeles
time zone, wrap {% else %}
and {% endif %}
tags around an {% abort_message () %}
tag.
1
2
3
| {% else %}
{% abort_message () %}
{% endif %}
|
Full Liquid code
1
2
3
4
5
| {% if {{${time_zone}}} =='America/Los_Angeles' %}
Stream now!
{% else %}
{% abort_message () %}
{% endif %}
|

You can also abort messages based on Connected Content.