Dynamic Content - Reference Guide


Overview

Dynamic content in mailings is controlled by IF ... ELSEIF ... ELSE ... END IF condition sets that are evaluated against mailing list columns to select specific content. Each condition within the set is defined by {{% and }} and is immediately followed by the statement body.

E.g.

Hello {{% IF state = 'IL'}}Illinois{{% ELSE }}other state{{% END IF }}

In the example above, if the recipient's state value is IL, "Illinois" will be placed in the mailing content. In all other cases "other state" appears in the mailing content.

Condition Sets

Condition sets are started with {{% IF [statement]}} and finished with {{% END IF}}. If either of those anchors are missing the condition set will not be extracted from the content for evaluation.

  • Condition sets can have many ELSE IF conditions but only one IF. IF conditions found after the first position in the set will be converted to ELSE IF.
  • Condition sets do not need to specify ELSE. Evaluations that match no conditions will return an empty string.

Conditions

A full condition consists of the formatted condition, plus a statement, and statement body.

  
                                  +---------------------- Statement --------------------+
                                  |                                                     |
    Boundary    Condition Type    Statement Column   Statement Operator   Statement Value    Boundary    Statement Body
       |              |                    |                  |                  |              |              |
       |              +------------+       |                  |                  |   +----------+              |
       |                           |       |                  |                  |   |                         |
       +-------------------- {{%   IF    state             EQUALS               'IL' }}Illinois ---------------+

Valid condition types are

  • IF,
  • ELSEIF, and
  • ELSE

Statements

IF and ELSEIF conditions must include a statement to evaluate. Statements consist of a column (equivalent to a mailing list column), an operator, and a comparison value.

Statement Operators

Supported operators are

  • EQUALS,
  • IN,
  • GREATERTHAN,
  • GREATERTHANOREQUALS,
  • LESSTHAN, and
  • LESSTHANOREQUALS

Some operators can be aliased as described in the following table.

Operator Supported Aliases
EQUALS EQ, IS, =, ==
GREATERTHAN GREATER_THAN, GT, >
GREATERTHANOREQUALS GREATER_THAN_OR_EQUALS, GTE, >=
LESSTHAN LESS_THAN, LT, <
LESSTHANOREQUALS LESS_THAN_OR_EQUALS, LTE, <=

Statement Values

The statement value will be evaluated against the recipient list column value. It can be an integer or a string.

Parsing

The condition set parser attempts to be as generous as possible and will record errors rather that invalidate a whole condition set. Parsed conditions are subject to secondary validation during the evaluation process. Conditions that fail parsing are omitted from the condition set and are stored as error results.

  • Whitespace doesn't matter. {{%IFstate='IL'}} is as valid as {{% IF state = 'IL'}}
  • Casing does matter, condition types and operators must all be uppercase. {{%ifstate='IL'}} and {{%if state = 'IL'}} will be errors.
  • Quoting doesn't matter for statement values. IL, 'IL', and "IL" are all equivalent as are 1, '1', and "1". The evaluation code handles type conversion.
  • Statement values that are strings do not need to be quoted. my value and 'my value' are both valid.
  • When using the IN operator, the statement value should be an array. E.g. [IL, WI, MI, MN]. As with the other statement values, quoting the values in the array is not required.

Validation

During the replacement context building process, conditions in the set are validated and may be marked as invalid. The validation matrix is described in the following table.

Condition Column Required Column Exists Operator Required Value Required
IF Y Y Y Y
ELSE N N N N
ELSEIF Y Y Y Y
  • Statement bodies are not required. If left empty an empty string will be inserted in the HTML or text.
  • Columns must be valid recipient list columns.

Evaluation

When condition sets use a first past the post evaluation process. I.e. the first match returns the replacement content,

E.g.

  {{% IF city = 'CHI'}}The Windy City{{% ELSE IF city = 'CHI'}}Chi-town{{% ELSE IF city = 'NY'}}The Big Apple{{% END IF}}

In the above example, recipients with a city matching 'CHI' would get 'The Windy City' in the content.

If there is no match in a condition set and the ELSE condition is not defined, an empty string will be inserted.

×

Contact Us

Support Resources

ReachMail is here to help. If you have any questions, please use the form below or contact us at:

Support Hours: 8am - 6pm (Central Time) Mon-Fri