Skip to main content

(5 min read)

Personalizing an email using the data you've collected about your supporter will encourage them to open your message, click on your links, and join or give to your organization. Studies show that supporters who read an email that has specific information that reflects their interests and history with your organization are 6 times more likely to respond in some way.

But there is no need to create an individual email for each of your supporters. You can create one Targeted Email and then use the power of Conditional Content to pull the data you need from their record and include the right ask or display the exact information you want them to see.

 

Understanding Conditional Content



Conditional Content basically requires that you create a Conditional Statement that consists of Merge Fields which pull data from the contact record and then adding Macros (like if equals, elseif equals, and so on) to make comparisons and display specific information depending on the results of your comparisons.


For example, if the People for Good's national organization wanted to send out an email that reflected the correct state for each affiliate, the conditional statement for the subject line might look something like this:

People for Good{{ if equals(StateOrProvince,'NH') }} New Hampshire Chapter 
{{ elseif equals(StateOrProvince,'FL' }} Florida Chapter
{{ else }} National Organization {{ end }}


Supporters would see different subject lines depending on which state matched their local office:

Subject Line.jpg

 

 
To use a macro, you will add the name of the macro to your statement, and then two values you wish to compare. The basic form looks like macro_name(value1, value2).

A few of the more common macros are:
 

ExpressionDescription
equals(X,Y)X is equal to Y
not_equals(X,Y)X is not equal to Y
less_than(X,Y)X is less than Y
greater_than(X,Y)X is greater than Y
less_than_or_equal_to(X,Y)X is less than or equal to Y
greater_than_or_equal_to(X,Y)X is greater than or equal to Y

 

There are many more macros that are available to help you create your conditional statement.
 

 

Creating your conditional statement


Conditional statements must always start with two opening curly brackets, {{, and end with two closing curly brackets. The syntax of everything between the brackets is very important. If you were to use an extra bracket, apostrophe, equal sign, or forget a space, your email could fail to send.

To help you get started, here are a few sample conditional statements:

Basic IF statement

Every conditional statement must start with {{ if }} and close with {{ end }}.

{{ if MergeField }}
Content you want shown if any value exists for this field.
{{ end }}


Using IF with a comparison operator
 

{{ if equals(MergeField, 'value') }}
Content you want shown if the preceding statement is true.
{{ end }}

 

Using IF and AND
 

{{ if MergeField and equals(MergeField, 'value') }}
Content you want shown if the Merge Field exists and equals the value in the comparison.

 

Using IF and ELSE

You do not need to provide an {{ else }} statement but you must provide an {{ end }} statement.
 

{{ if MergeField and equals(MergeField,'value') }}
Content to be shown if the preceding statement is true.
{{ else }}
Content to be shown if the preceding statement is false.
{{ end }}

 

Using IF and ELSEIF

You can construct more complex conditionals by using the {{ elseif }}, which allows you to provide an additional comparison if the preceding comparison is false. You can daisy chain as many of these {{ elseif }} statements as you like but remember, you must always start with {{ if }} and close with {{ end }}. 
 

{{ if MergeField and equals(MergeField, 'Value1') }}
Content to be shown if the preceding statement is true.
{{ elseif MergeField and equals(MergeField, 'Value2') }}
Content to be shown if the preceding statement is true.
{{ elseif MergeField and equals(MergeField,'Value3') }}
Content to be shown if the preceding statement is true.
{{ else }}
Content to be shown if the preceding statement is false.{{ end }}

 

Using IF, ELSE and AND:

You can use AND to put more than one comparison expression in a single IF statement. Both comparisons must resolve to true for the content following the IF statement to be shown. 
 

{{if MergeField and StateOrProvince == 'VA' and CongressonalDistrict == '010'}}
Content you want shown to just supporters in Virginia Congressional District 10
{{else MergeField and if StateOrProvince == 'VA' }}
Content you want shown to supporters in Virginia. Virginians who are in CD10 will not see this content.
{{else}}
Content you want shown to all other supporters.
{{end}}

 

Nested IF statements

{{if StateOrProvince and StateOrProvince == 'VA'}}
	  {{if CongressonalDistrict and CongressonalDistrict == '010'}} Virginia CD 10 content {{end}}
          {{if CongressonalDistrict and CongressonalDistrict != '010'}} content for everyone else in Virginia (not in Virginia CD 10) {{end}}
      {{else}} content for everyone else (not in Virginia)
{{end}

 

EACH statement to iterate over an array

For merge fields that return multiple values (Gender, Race, Ethnicity, SexualOrientation, EventLocations, EventShifts, AddToCalendarLinks), you can use the "Array" version of those merge fields ((GenderArray, RaceArray, EthnicityArray, SexualOrientationArray, EventLocationsArray, EventShiftsArray, AddToCalendarLinksArray)) with "each" and "loop_var" syntax to apply your own formatting.
 

{{each GenderArray}} {{loop_var}}<br />
{{end}}</p>


In Targeted Email, these conditionals will work in both the subject line and body of the email.

The tags themselves do not matter for formatting, in that they will not add extra spaces, or line breaks. For example:

Hello Friend,
{{ if equals(StateOrProvince,'MA') }}
Have you been to our Boston events?
{{ else }}
Have you been to any of our events?
{{ end }}
If you haven't, you should go to our next event.


Will return as:

Hello Friend,
Have you been to our Boston events?
If you haven't, you should go to our next event.

 

Read more about using contribution fields in Conditional Content



Troubleshooting your conditional statement

 

It is very important to understand how the data is stored in order to have the values properly replaced in your email. In the examples above, if you replace 'NH' with 'New Hampshire,' the New Hampshire recipient would have received the default value ("People for Good National Organization") since the macro is looking for the exact match "New Hampshire". States are stored as the two-letter abbreviation on contact records.
 

To ensure that you're using the correct format for comparisons in your conditional content, we strongly recommend configuring an email with the merge fields in question and sending it to your own email address to understand how each stored value is formatted. For example, just as you would want to use 'NH' for State, you'd also want to use 'M' and 'F' for Sex. Note that the StateHouse and StateSenate value formats can vary by state. 


 

Be the first to reply!