Operators
Liquid supports many operators that can be used in your conditional statements.
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 |
Operator examples
Here are some examples of how these operators could be helpful for your marketing campaigns:
Choose message via integer custom attribute
1
2
3
4
5
{% if {{custom_attribute.${total_spend}}} >0 %}
Thanks for purchasing! Here's another 10% off!
{% else %}
Buy now! Would 5% off convince you?
{% endif %}
In this example, if a customer’s “Total Spend” custom attribute is greater than 0
, they will get the message:
1
Thanks for purchasing! Here's another 10% off!
If a customer’s “Total Spend” custom attribute does not exist or is equal to 0
, they will get the following message:
1
Buy now! Would 5% off convince you?
Choose message via string custom attribute
1
2
3
4
5
6
7
{% if {{custom_attribute.${Game}}} == Game1 %}
You played our Game! We're so happy!
{% elsif{{custom_attribute.${Game}}} == Game2 %}
You played our other Game! Woop!
{% else %}
Hey! Get in here and play this Game!
{% endif %}
In this example, if you have played a certain game, you’ll receive the following message:
1
You played our Game! We're so happy!
If you played another specified game:
1
You played our other Game! Woop!
If you haven’t played any games, or that custom attribute doesn’t exist on your profile, you’d get the following message:
1
Hey! Get in here and play this Game!
Abort message based on location
You can abort a message based on just about anything. The following example shows how you can abort a message if a user is not based in a specified area, as they might not qualify for the promotion, show, or delivery.
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.