How do I personalize emails with Conditional Content?
Conditional Content lets you show different text, images, or sections to different recipients based on information in their contact record — all within a single email. Follow the steps below to create your first conditional statement.
Step 1: Understand the basic structure
Every conditional statement opens with {{ if }} and closes with {{ end }}. Everything between them is shown only when the condition is true.
Syntax matters: use two curly brackets to open and close every statement. A missing bracket, extra space, or typo will prevent your email from sending.
Basic structure:
{{ if MergeField }} Content shown if a value exists for this field. {{ end }}
Step 2: Write your conditional statement
Common conditional patterns:
IF with a comparison: {{ if equals(MergeField, ‘value’) }} Content shown if the field equals the value. {{ end }}
IF and ELSE: {{ if MergeField and equals(MergeField,‘value’) }} Content shown if true. {{ else }} Content shown if false. {{ end }}
IF, ELSE IF, ELSE (multiple conditions): {{ if equals(StateOrProvince,‘NH’) }} New Hampshire content {{ elseif equals(StateOrProvince,‘FL’) }} Florida content {{ else }} Default content {{ end }}
IF with AND (both conditions must be true): {{ if MergeField and StateOrProvince == ‘VA’ and CongressionalDistrict == ‘010’ }} Content for Virginia Congressional District 10. {{ else }} Content for everyone else. {{ end }}
Nested IF statements: {{ if StateOrProvince and StateOrProvince == ‘VA’ }} {{ if CongressionalDistrict and CongressionalDistrict == ‘010’ }} Virginia CD 10 content {{ end }} {{ if CongressionalDistrict and CongressionalDistrict != ‘010’ }} All other Virginia contacts {{ end }} {{ else }} Content for non-Virginia contacts {{ end }}
Step 3: Use EACH for merge fields with multiple values
Some merge fields return multiple values (for example, GenderArray, EventLocationsArray). Use the EACH statement to loop through them:
{{ each GenderArray }} {{ loop_var }} {{ end }}
Step 4: Test your conditional statement
Conditional content works in both the subject line and body of the email.
The conditional tags themselves don’t add extra line breaks or spaces — the formatting you see in the editor is what recipients will see.
To verify your syntax, send a test email to your own address. Make sure you’re using the correct format for the values you’re comparing. For example, states are stored as two-letter abbreviations (NH, not New Hampshire). If the value format doesn’t match what’s stored in the contact record, recipients will see the else or default content instead.
Step 5: Troubleshoot if something doesn’t look right
If your conditional statement isn’t showing the expected content, check:
-
That you’re using the correct value format (two-letter state codes, ‘M’ and ‘F’ for Sex, and so on)
-
That every {{ if }} has a matching {{ end }}
-
That you haven’t accidentally deleted a curly bracket or added an extra one
-
That any comparison strings are wrapped in single quotes
Not quite what you were searching for?
- Navigate back to the Understanding Email Personalization Resource Index.
How do I use conditional content in Targeted Email? | How do I show different content to different states in EveryAction? | How do I write an if else statement in Targeted Email? | How do I use elseif in Targeted Email conditional content? | How do I test my conditional content in EveryAction? | How do I use AND in a conditional statement in Targeted Email? | How do I loop through an array merge field in Targeted Email?
