Conditional Merge Tags
Conditional merge tags control what content is displayed in an email based on subscriber or organisation data. They allow different content to be shown depending on whether defined conditions are met at send time.
Example: Display a gender-specific greeting
This example displays “Hello Mr” or “Hello Mrs” depending on the value stored in a Gender custom field.
{{#if (eq [GENDER] 'Male') }}Hello Mr{{else}}Hello Mrs{{/if}}
Using Conditional Merge Tags as a Fallback
Conditional merge tags can be used to display alternative content when a merge tag does not contain a value.
Example: Display a fallback greeting when the first name is empty
This example displays “Hi First Name” when a first name exists, or “Hi there” when it does not.
Hi {{#if (eq [FIRSTNAME] '') }}there{{else}} {{FIRSTNAME}}{{/if}},
Replace FIRSTNAME with the merge tag name for your first name custom field.
Nesting Conditional Merge Tags
Nested conditional merge tags allow one condition to be evaluated only when another condition is met. This is useful when additional logic applies to a specific subset of contacts.
Example: Display a different message for male and female subscribers, and applies an additional condition only to male subscribers who like shoes.
{{#if (eq [GENDER] 'Male') }}
{{#if (eq [LIKESSHOES] 'YES') }}
Hello Shoe Lover!
{{else}}
Hello Mr Non Shoe Lover
{{/if}}
{{else if (eq [GENDER] 'Female']}}
Hello Mrs
{{else}}
Hello There
{{/if}}
In this example, the second condition is evaluated only for subscribers whose gender is set to Male.
And OR?
Conditional merge tags support logical operators to define more specific rules. Use these operators when a single condition is not sufficient.
OR Conditions
Use OR when content should be displayed if any condition is met.
Example: Display content for male subscribers or subscribers aged 30
{{#if (or (eq [GENDER] 'Male') (eq [AGE] '30') ) }} Hello Mr {{/if}}
In this example, the content is displayed when either condition evaluates as true.
Example: Display content for female subscribers or subscribers aged 40 or over
{{#if (or (eq [GENDER] 'Female') (gte [AGE] 40) ) }} Hello Mr {{/if}}
In this example, the content is displayed when the subscriber’s gender is Female, or their age is greater than or equal to 40.
Comparison Operators
The following operators can be used when defining conditions:
gte— Greater than or equal tolte— Less than or equal togt— Greater thanlt— Less thaneq— Equalsne— Does not equal
AND Conditions
Use AND when all conditions must be met.
Example: Display content only when gender and age both match
{{#if (and (eq [GENDER] 'Female') (eq [AGE] 40) ) }} Hello Mr {{/if}}