Guide to Merge Tag Conditional Statements

Conditional statements allow you to easily implement basic logic into your behavioural targeting actions and webpage widgets. This will allow you to harness greater control over what appears to your website’s visitors.

Let’s say you have a lightbox, an email, or a banner, that will appear to a certain group of visitors. You may want to personalise that lightbox by including the name of each visitor at the top. To do this you would use a replacement tag, like so:

Hello *|FORENAME|*, here’s a special offer for you…

However, on many occasions there many not be any data to replace the tag with. In the latter example, a visitor may trigger the action without their name being known. In this case, the latter line would appear to that visitor as:

Hello , here’s a special offer for you…

To prevent this from happening you can use replacement tag conditional statements. The syntax is as follows:


Conditional statements consist of three commands, two mandatory and one optional. They are:

  1. *|IF||* – mandatory. Begins the conditional statement. The value between the quote marks (value1) is the replacement value you are testing.
  2. *|ELSE|* – optional. Separates the two values, value2 and value3. value2 is the text / HTML to show if the replacement value is known. value3 is the text / HTML to show if the replacement value is not known. If the *|ELSE|* command is omitted then nothing will be shown at all if the replacement tag in *|IF|* is not known.
  3. *|ENDIF|* – mandatory. Ends the conditional statement.

Returning to the original example, the following line would show the visitor “Hello Joe” if the visitor’s name is Joe, or “Hello stranger” if the visitor’s name is unknown:

Hello *|IF|*|FORENAME|*|**|FORENAME|**|ELSE|*stranger*|ENDIF|*, here’s a special offer for you…

The two values can be as long or as short as you want. They can also contain HTML. The following will hide or show an email entry box, depending on whether the visitors’ email address is known or not:

*|IF|*|EMAIL|*|*<style type=”text/css”>#email_box { display:none; }</style>|*ELSE*|Your email address is unknown.<br />Please enter it below:*|ENDIF|*

You enter as many conditional statements as you want per action or widget, but you cannot embed conditional statements within one another. The three commands are case sensitive, and must be entered exactly how they appear above in uppercase letters.

Replacement tag conditional statements give you the freedom to easily implement basic logic into your website personalisation actions, so give them a try!