Please note:
To unlock this capability, you will need to have added SMS to your Optimove package. If you can’t see this feature in your Optimove instance, contact your CSM to find out more.
A conditional clause is an if/then or if/then/else condition that personalizes or hides content within a template, per individual recipient.
You can use conditional clauses to customize the content of SMS templates based on any customer attribute/activity.
You can use conditional clauses to customize the content of SMS templates based on any customer attribute/activity.
Conditions are written in Liquid. To add one, click the insert icon (≡+) next to the Content box and select Conditional Language. Click the condition type you need, and the editor adds it to your message. Then replace
YOUR.TAG with the personalization tag you want to check, for example customer.AverageOrderAmount, and add the content to display. The editor shows each condition and tag as a chip.IF Clauses
Only recipients who match the clause will see the section of the template. For all other recipients, the section of the template will be hidden.
{% if customer.YOUR_TAG %}Content to display
{% endif %}In this example, only customers whose Average Order Amount is lower than $200 (
{% if customer.AverageOrderAmount < 200 %}) will receive the content "Get 20% off next order with code GET20", as an incentive to get them to spend more. All other customers will just see "Hey [FirstName]! Check out new items in the sale now 🛍"IF/ELSE Clauses
Recipients who match the clause will see the defined section of the template. All other recipients will see the section set under the “else” condition.
{% if customer.YOUR_TAG == "TEXT" %}Content to display
{% else %}Alternative content
{% endif %}In this example, customers whose Average Order Amount is lower than $200 will receive the content "Get 20% off next order with code GET20", as an incentive to get them to spend more. We still want to give other customers an incentive, but if they usually spend a higher amount anyway we want to give a lower offer. So they will just see "Get 10% off next order with code GET10".
IF/ELSEIF Clauses
Recipients will receive the content they match based on the determined clauses. Recipients that don’t match any of the clauses will see the content set under the “else” condition.
{% if customer.YOUR_TAG == "TEXT" %}Content to display
{% elseif customer.YOUR_TAG > NUMBER %}Alternative content
{% else %}Alternative content
{% endif %}In this example, we want to give three different incentives - high, medium, and low - depending on the Average Order Amount. For those who spend over $200, they will receive the lowest incentive as they already have the desired behavior. For those who spend over $100 (but not higher than $200), they will receive the medium incentive, to encourage a slightly higher spend. For those who don't meet either of the above criteria, so have an Average Order Amount of $100 or less, they will receive the highest incentive to convince them to purchase and spend more.
Supported Condition Types and Operators
Condition |
Usage |
Definition |
|---|---|---|
if |
{% if customer.YOUR_TAG %}Content to display
{% endif %} |
If the clause is evaluated as true, display the content. Otherwise, hide it.
For example:
{% if customer.FAVORITE_PRODUCT %}Special offer for {{ customer.FAVORITE_PRODUCT }}
{% endif %} |
else |
{% if customer.YOUR_TAG == "TEXT" %}Content to display
{% else %}Alternative content
{% endif %} |
Use else to display alternative content if the first clause is evaluated as false.
For example:
{% if customer.AverageOrderAmount >= 200 %}Content for those customers
{% else %}Content for other customers
{% endif %} |
elseif |
{% if customer.YOUR_TAG == "TEXT" %}Content to display
{% elseif customer.YOUR_TAG > NUMBER %}Alternative content
{% else %}Content
{% endif %} |
Use elseif to define multiple alternative content blocks.
For example:
{% if customer.AverageOrderAmount >= 200 %}Content for customers with high order value
{% elseif customer.AverageOrderAmount >= 100 %}Content for customers with medium order value
{% else %}Content for customers with low order value or no orders
{% endif %} |
Text values go in double quotes, for example
{% if customer.COUNTRY == "Canada" %}. Numbers don’t need quotes.Operator |
Meaning |
|---|---|
No operator |
True if the personalization tag has a value (an empty text value also counts as a value) |
== |
Equal to |
!= |
Not equal to |
> |
Greater than |
< |
Less than |
>= |
Greater than or equal to |
<= |
Less than or equal to |