Transactional Email supports conditional merge tags. Because Transactional Email does not store list data, all merge tag values need to be provided in the API call or SMTP headers, and the conditions would be checking against those values.
Conditional merge tags support traditional IF, ELSE, and ELSEIF logic and IFNOT negative conditions.
Examples
Basic IF and ELSE conditions
Use IF conditions to display content only when the condition evaluates as true.
*|IF:MERGE|*
content to display if a value for MERGE is provided
*|END:IF|*
*|IF:MERGE=x|*
content to display if the value for MERGE is x
*|END:IF|*
When using a condition like *|IF:MERGE=x|*
, and no value for MERGE
is provided, the condition will evaluate as false.
Use IF and ELSE conditions to display content when a condition is true, but alternate content when the condition evaluates as false.
*|IF:MERGE|*
content to display
*|ELSE:|*
alternative content
*|END:IF|*
The ELSEIF condition
Use ELSEIF to display one of several options. Only the content following the first condition evaluated as true display—it will skip other conditions.
*|IF:MERGE=x|*
<p>content to display if the value for MERGE is x</p>
*|ELSEIF:MERGE=y|*
<p>content to display if the value for MERGE is not x, but is y</p>
*|ELSEIF:MERGE=z|*
<p>content to display if the value for MERGE is not x or y, but is z</p>
*|ELSE:|*
<p>alternate content to display if the value for MERGE is not x, y, or z</p>
*|END:IF|*
Nested conditions
*|IF:MERGE1=x|*
*|IF:MERGE2=y|*
<div mc:edit="main">
<p>content to display if both conditions are true</p>
</div>
*|END:IF|*
*|END:IF|*
Negative conditions
*|IF:MERGE!=x|*
content to display if the value for MERGE is not x
*|ELSE:|*
content to display if the value for MERGE is x
*|END:IF|*
*|IFNOT:MERGE|*
content to display if MERGE is not provided
*|ELSE:|*
content to display if MERGE is provided
*|END:IF|*