The drag-and-drop template builder allows you to use contacts' profile properties and event variables to control who sees a given block in a single email template. If you click the ? mark in the block editor for a given block, you can configure the block to show only when certain a profile property is true for the recipient. You can also create a condition around an event variable if your email is triggered by a flow.
After clicking this ? icon, you will be prompted to set a condition that determines whether or not the block is shown. Make sure to then toggle the On button to enable this feature.
Show or Hide a Block-Based On a Profile Property
Profile variables can be found in the Custom Properties section of a person's profile when you go to the Profiles tab. The format is always person.[Custom Property Name]. In the example below, this block will only appear for recipients who live in Canada.
Logical operators that can be used here:
- Show block if property equals A: person.Country = "A"
- Show block if property doesn't equal A: person.Country != "A"
- Show block if property isn't set: not person.Country
- Show block if property doesn't equal A or B: person.Country != "A" and person.Country != "B"
You can use "or" statements to target people who have inputted one custom property or another. For example, you may want to target people who live in Boston OR Providence:
- Show block if property equals Boston or Providence: person.City = "Boston" or person.city = "Providence"
However, please note that if you want to target people who do NOT live in Boston or Providence, you would use the following logic:
- Show block if property doesn't equal Boston or Providence: person.City != "Boston" and person.City != "Providence"
This is because you want to capture people who do not live in Boston AND people who do not live in Providence.
Show or Hide a Block Based on an Event Variable
If you are building an email template within a flow, you can also formulate a condition around an event variable. Let's say, for an abandoned cart email, you would only like to show a certain block when someone's cart contained more than one item. First, find the event variable that corresponds with what you are looking to target.
The variable we want to target in this example is Item Count:
We then need to configure a short condition statement that tells the block to only show if Item Count is greater than 1.
The event variable we're going to use, copied from the preview window, is event|lookup:'Item Count'.
The condition statement we need to create is: event|lookup:'Item Count' > 1
Now this template block will only show to a recipient if the condition statement evaluates to True.
Show or Hide Based on Gender
To follow this example, you will have to have gender information stored as a custom property for your contacts. You can start collecting gender information from your customers and subscribers by asking in sign up forms or within emails.
Here is the logic you would use for each block to achieve the following:
- Show if Gender is set as Male: person.gender = "male"
- Show if Gender is set as Female: person.gender = "female"
- Show if Gender is not set: not person.gender
- Show if Gender is not Male or Female: person.gender != 'male' and person.gender != 'female'
Like we mentioned previously, you can use "or" statements to target people who have inputted one custom property or another. For example, you might want to ensure that you capture different possible spellings of a word when you are targeting subscribers who have described themselves as "male" OR "Male." To do this, you would use the following syntax:
- Show if Gender is set as Male or male: person.gender = "male" or person.gender = "Male"