Conditions

Allows to display various parts of message depending on campaign or contact or message_info, contact custom fields or tags, contact geo location or dates.

{{IF "(pet IS_DEFINED)"}}
    {{IF "(pet STRING_EQ 'dog')"}}
        Buy a bone for your dog! {{LINK "http://mysite.com/shop/product/bone_for_dog"}}
    {{ELSIF "(pet STRING_EQ 'cat')"}}
        Buy a mouse toy for your cat! {{LINK "http://mysite.com/shop/product/toy_mouse_for_cat"}}
    {{ELSE}}
        You may find something for your pet in my store!
    {{ENDIF}}
{{ELSE}}
    You don't have a pet yet. Buy one!
{{ENDIF}}

{{IF "((city STRING_EQI 'Gdańsk') LOGIC_OR ((city STRING_EQI 'Gdynia') LOGIC_OR (city STRING_EQI 'Sopot')))"}}
    You can visit our store located in 3City in person!
{{ELSE}}
    Go to our online page: {{LINK "http://mysite.com/shop"}}
{{ENDIF}}

{{IF "(day_name STRING_NEQ 'Sunday')"}}
    We're open today.
{{ELSE}}
    Please visit us from Monday to Saturday
{{ENDIF}}

Order of tags:

  • {{IF "..."}} – Mandatory beginning of conditional statement.
  • {{ELSIF "..."}} – Optional block, multiple allowed.
  • {{ELSE}} – Optional default block, one allowed.
  • {{ENDIF}} – Mandatory closing of conditional statement.

Building conditions step by step:

  • Take left operand, this can be name of contact custom field or tag or token from campaign or contact or message_info, contact geo location, dates.
DAY 
  • Lowercase this operand.
day 
  • Take right operand which is constant value you like left operand to be compared against.
8 
  • Quote this operand in single quotes, this is mandatory even if operand is numeric.
'8' 
  • Join operands with operator.
day NUMBER_GT '8' 
  • Wrap this pair in round brackets to get conditional statement.
(day NUMBER_GT '8') 
  • (optional) If you need more complex logic you can join conditional statements with logic operator. Remember about top round brackets to create conditional statement.
((day NUMBER_GT '8') LOGIC_AND (day NUMBER_LT '16')) 
  • Use conditional statement in tag param.
{{IF "((day NUMBER_GT '8') LOGIC_AND (day NUMBER_LT '16'))"}} You will see this if message was sent between 8th and 16th day of month. {{ENDIF}} 

Operators:

  • NUMBER_LT – Less than.
  • NUMBER_GT – Greater than.
  • NUMBER_EQ – Equal.
  • NUMBER_NEQ – Not equal.
  • NUMBER_GEQ – Greater or equal.
  • NUMBER_LEQ – Less or equal.
  • STRING_EQ – Equal.
  • STRING_EQI – Equal but case-insensitive.
  • STRING_NEQ – Not equal.
  • STRING_NEQI – Not equal case-insensitive.
  • LOGIC_OR – Union used if A and B are conditions.
  • LOGIC_AND – Intersection used if A and B are conditions.
  • IS_DEFINED – Check for value presence. Only left operand is required - (car IS_DEFINED).
  • NOT_DEFINED – Check for value absence. Only left operand is required - (car NOT_DEFINED).

Warning: If you use (pet STRING_EQ 'dog') and contact custom field pet is not defined then the statement will evaluate to false. In most cases this is what you mean, but it is better to use additional IS_DEFINED operator to keep logic clean.

Warning: If you apply NUMBER_* operator to not numeric value it will evaluate to false.

Warning: If custom field in condition is multi value then conditional statement will evaluate to true if any element matches it. So if custom pet has values "mouse" and "hamster" then (pet STRING_EQ 'mouse') is true because "mouse" value meets the condition, but also (pet STRING_NEQ 'mouse') is true because "hamster" value meets the condition.

Mangling:

Mangling allows you to use contact custom field name or tag name or token name as left operand without having to worry about its tag type. For example if you use (city STRING_EQI 'Gdańsk') then:

  1. Value of contact custom field city is checked. If it exists conditional statement is resolved to true or false at this stage.
  2. City is also token in contact geo location. If it exists and conditional statement is not yet resolved then conditional statement is resolved to true or false at this stage.
  3. Conditional statement is false if not yet resolved.

Presence of custom/tags of given name is always checked before presence of such named token in other tags. Do not nest whole tags, for example  {{IF "{{CUSTOM "pet"}} STRING_EQ 'dog'"}} is not correct syntax.