We already described how to use merge tags to make your emails more personal in this article. Here, we will show you how to work with conditional merge tags and personalize not only first names, last names and individual words, but also how to personalize the entire text content. For example, with conditional merge tags, you can set who gets what text and who doesn't get any text at all. You can do this by using conditions.
Basic conditions IF, ELSE
Use IF for when you want to display content when a condition is met:
*|IF:NAME|*
Content that shows if your recipient has its name filled
*|END:IF|*
*|IF:NAME=John|*
Content that shows if your recipient's name is John
*|END:IF|*
Use ELSE to add text that will be shown if the condition isn't met.
*|IF:NAME|*
Hello, *|NAME|*
*|ELSE:|*
Hi!
*|END:IF|*
Using ELSEIF
You can use ELSEIF to test multiple conditions, for example, if you wish to show different content for people based on the information filled in some of the fields. For this case you can use ELSIF notation as follows:
*|IF:PLACE=New York|*
Go see Times Square
*|ELSEIF:PLACE=London|*
Go see the Buckingham Palace
*|ELSEIF:PLACE=Paris|*
Go see the Eiffel tower
*|ELSE:|*
Go somewhere nice
*|END:IF|*
Negative conditions
Here is an example of an entry where you need to test if the condition is negative:
*|IF:NAME!=Danny|*
Hi friend! Your name isn't Dannny.
*|ELSE:|*
Hi Danny!
*|END:IF|*
Most commonly used conditional merge tags
a) Condition based on gender
An example for using system-generated gender:
*|IF:GENDER=male|*
Dear Mr *|VOKATIV_S|*
*|ELSEIF:GENDER=female|*
Dear Mrs *|VOKATIV_S|*
*|ELSE:|*
Good afternoon,
*|END:IF|*
According to this example, if the gender is known and it is male, this part of the email will appear as "Dear Mr Novak". In case the gender is set as a female "Dear Mrs Novak", and in case the gender is unknown, the generic text "Good afternoon" will be used.
b) Condition based on a custom field and multiple conditions
Here you can see an example, where if the contact has a nickname filled, you greet him with a nickname. If they don't, you simply greet them with "Hi there!".
Below, you can see a little more complex condition where if the contact has a nickname, then you greet them with the nickname. If the contact does not have a nickname listed, the condition checks, whether they have a vocative. If they do, the condition will greet them by the vocative. If the contact doesn't have a vocative either, the condition will then simply write out a greeting.
Composite conditions
You can easily merge conditions to create an even more personalised experience. Here is an example where you are primarily interested in the existence of the last name, then a first name, and then you address those who have neither of these values:
*|IF:VOKATIV_S|*
*|IF:GENDER=male|*
Dear Mr *|VOKATIV_S|*
*|ELSEIF:GENDER=female|*
Dear Mrs *|VOKATIV_S|*
*|ELSE:|*
Hello there,
*|END:IF|*
*|ELSEIF:VOKATIV|*
*|IF:GENDER=male|*
Hey, *|VOKATIV|*
*|ELSEIF:GENDER=female|*
Hi, *|VOKATIV|*
*|ELSE:|*
Hello,
*|END:IF|*
*|ELSE:|*
Hello,
*|END:IF|*
For example, Jane who doesn't have her last name filled will have "Hi, Jane" in her email, while John, who has his last name filled will have "Dear Mr Snow" in his email.
If you are inserting html code into the template using a merge tag, which should be written as html code and not as text, it is necessary to put the merge tag in compound brackets {}, i.e. {*|CUSTOMURL|*}.