Home | Dynamic Content | Logical Operations for Dynamic Content

Logical Operations for Dynamic Content

ClickDimensions utilizes a scripting language called FreeMarker in order to render dynamic content in emails. FreeMarker can also perform other functions, such as setting up conditional statements to cause emails to show different blocks of content for recipients based on certain attributes that are referenced from their lead or contact records in CRM. By default, conditional statements can only be used to check against one variable at a time and can only check if a positive condition is met. However, it is possible to expand this functionality to check if one of a set of conditions is met, to check if several conditions are met or to check that a value is anything except a certain value.

Note: I recommend reviewing this article for guidelines on formatting conditional statements prior to attempting to utilize the operators discussed here.

Logical OR: ||

FreeMarker uses two parallel lines to represent “OR.” This operator allows you to create conditional statements where a recipient should be able to see content if they meet at least one of a couple different criteria. The “||” allows you to be less strict with your defining logic or cut down on the number of different checks you have to perform if certain groups of recipients with different information should see the same content, but not necessarily all of the recipients. A statement using the “||” operator would look like this:

<#if Recipient.contact.position == “President” || Recipient.contact.position == “Vice-President”>

In this case, the statement would show the recipient the content following this conditional statement if the recipient’s position is “President” OR “Vice President,” but would not show it otherwise. “||” can be used to check for different values of the same criteria, such as the previous example using position, or it can be used to check different criteria, such as:

<#if Recipient.contact.position == “President” || Recipient.contact.stateorprovince == “DC”>

The recipient would see the content if their position is “President,” their state or province is “DC” or if both are correct.

Logical AND: &&

FreeMarker uses two ampersands to represent “AND.” This is the opposite of “||” in that you can use it to check if a recipient meets all of a set of criteria at once in order to determine if they can see certain content in your email. The “&&” operator could be useful in situations where there are multiple levels of checks being performed, such as if you are showing different content based on gender, but have that content included several times to account for different languages as well. A statement using the “&&” operator and checking the aforementioned language and gender criteria would look like this:

<#if Recipient.contact.language == “Spanish” && Recipient.contact.gender == “Male”>

In this case, the recipient would only see the content listed after this conditional statement if he is a male who speaks Spanish. If either criterion is not met, the recipient won’t be able to see the content.

Logical NOT: !

FreeMarker uses the exclamation mark to represent “NOT,” which allows you to base conditional statements on whether a certain field doesn’t contain a specific value. This is particularly useful in scenarios where you may be basing a conditional statement on a field that could have a number of predefined options, such as a list of users, job titles, etc, where you only want to show your email recipients content if they are not associated with a particular user or do not hold a certain position at their company. A statement using the “!” operator would look like this:

<#if Recipient.contact.firstname != “Rhys”>

In this case, the statement would be used to indicate that the following content should only be shown to recipients whose first name is not “Rhys.”

All of these operators can be used in the same email template if need be. Try using them and see how they can help expand your formatting options when creating templates!

About the Author:

mm
Rhys Saraceni is a Training Developer at ClickDimensions.

Leave A Comment