Conditional Functions
if/else Function
The #if
helper function is used to verify whether a value of a user or event attribute exists or is true. Upon message dispatch, if the verified attribute's value is equal to false
, undefined
, null
, ""
, 0
, or []
, CrossEngage will not render the block.
The syntax of this helper function is:
Property | Description |
| The user or event attribute that is used for the verification. e.g. |
Use Cases
Display content only if it exists
For this example, we only display the user's first name if it exists.
Once the function is evaluated, it displays either:
or
cif/else Function
CrossEngage offers a more advanced version of the #if
helper function that allows you to perform additional operations and only display content if a certain criteria is met.
The syntax of this helper function is:
For a list of operators that can be used for comparison, please check the Operators page.
Optionally, you may use the {{else}}
block that will display other content if the condition is not met. The {{else}}
block should be placed within the {{#cif}}{{/cif}}
tags for the function to be correctly processed.
Property | Description |
| The user or event attribute that is used for the verification. e.g. Please note that journey steps helper with array attribute e.g. cart is not supported for advanced If. |
| The operator that will be used to asses whether the criteria is met or not. e.g. |
| The value the |
Use Cases
Gender Based Salutation
For this example, we output the salutation of a client according to their gender.
Once the function is evaluated, it displays the salutation according to the user's gender. For example, the function may result in:
Dear Mr. Doe
, if the user is maleDear Mrs. Doe
, if the user is femaleDear Visitor
, if the user's gender is unknown
Stock Level Low
For this example, we output a call to action statement when the stock of a certain product is low.
Once the function is evaluated, if a product's stock is less than 4, it displays the content below in the section where it is used in the message.:
Last updated