Merge Tags
IN THIS ARTICLE
System Merge Tags | Custom Field Merge Tags | Organization Merge Tags |
Conditional Merge Tags | Nesting | And/Or |
Date Formatting |
Merge tags are extremely useful snippets of code that you can insert into your email body and subject lines to insert personalisation.
For example. you have a custom field called "First Name" and you would like to insert each customers first name into the emails as they go out.
Merge tags make this very easy, and can even be expanded out to perform more than just basic personalisation. You can also use rules to adjust what is shown on each email depending on the data associated with the subscriber.
For example if you have a GENDER custom field, you could send Hello Mr for all males, and Hello Ms or Mrs for all females.
You can also insert non-subscriber specific information, like unsubscribe links, today's date, and much more.
You can see a list of available merge tags whenever you are editing content. For example when editing text in the drag and drop editor, there is a INSERT drop down list that contains all of the available merge tags. When editing a WYSIWYG template there is a big "Merge Tags" button towards the bottom of the page.
System Merge Tags
There are a number of Merge Tags that are built into the system and can be used by everyone. They are as follows:
The Merge Tag | What it Does | |
{{{__UPDATE_URL}}} | The URL for Subscribers to View and Update their details. Use this in things like link HREF tags. For example <a href="{{{_UPDATE_URL}}}"> | |
{{{__UPDATE_LINK}}} | Inserts text that says "Update your Profile" and links to a page where subscribers can update their profiles. | |
{{{__UNSUBSCRIBE_URL}}} |
|
|
{{{__UNSUBSCRIBE_LINK}}} | Inserts text that says "Unsubscribe" and links to a page where subscribers unsubscribe from future mailings. | |
{{{__PREVIEW_URL}}} | The URL for Subscribers to View the Email in a browser. Use this in things like link HREF tags. For example <a href="{{{__PREVIEW_URL}}}"> | |
{{{__PREVIEW_LINK}}} | Inserts text that says "Preview in a Browser" and links to a page where subscribers can view the email in a web browser. | |
{{{__OPEN_LINK}}} | Insert's a hidden image that is used to track campaign opens. | |
{{{__JUNK_URL}}} | The URL for Subscribers to Report an email as junk. Use this in things like link HREF tags. For example <a href="{{{__JUNK_URL}}}"> | |
{{{__JUNK_LINK}}} | Inserts text that says "Report as Junk" and links to a page where subscribers can report the email as junk. | |
{{{__GDPRYES}}} | The URL for a GDPR Confirmation. Use this in things like link HREF tags. For example <a href="{{{__GDPRYES}}}"> | |
{{{__GDPRNO}}} | The URL for a GDPR Opt Out. Use this in things like link HREF tags. For example <a href="{{{__GDPRNO}}}"> | |
{{SUBSCRIBER_ID}} | The Id of the Subscriber | |
{{SUB_LAST_UPDATED}} | The date the subscriber record was last modified | |
{{SUB_EMAILADDRESS}} | The email address of the subscriber | |
{{SUB_DATE_JOINED}} | The date the subscriber joined | |
{{SENDING_ID}} | The Id of the Email | |
{{CURRENT_YEAR}} | The current year | |
{{CURRENT_DATE}} | The current date | |
{{CAMPAIGN_ID}} | The Id of the Campaign |
Custom Field Merge Tags
Any field you create using the platform can also be used as a merge tag.
When you add a custom field, you will be given the Merge Tag value. Simply insert this into your campaign as follows.
Assuming your custom field is name "Firstname", the merge tag would be:
{{FIRSTNAME}}
Organization Merge Tags
If your contacts are linked to Organizations in Transpond then you can insert organization details into your email templates as well.
The fields you can use are:
The Merge Tag | What it Does |
{{org_id}} | Inserts the ID for the Organization |
{{org_name}} | Inserts the Name for the Organization |
{{org_emailAddress}} | Inserts the email address for the Organization |
If you're using the Capsule integration then it will bring in more details for the organization records and those can be used in templates as well. When adding Merge tags you'll see them all available to select from.
Conditional Merge Tags
As well as inserting straight forward merge tags, there is also the option dynamically alter the data that is shown. We call this "Conditional Merge Tags" and they work a bit like a very basic programming language.
Lets say we want to show a "Hello Mr" or "Hello Mrs" at the top of our email, depending on wether the subscriber has a custom field called Gender.
We would write this:
{{#if (eq [GENDER] 'Male') }}Hello Mr{{else}}Hello Mrs{{/if}}
You can also use conditional Merge Tags to fallback to a word if a Merge Tag is empty - for example if you want to say 'Hi First Name' or if there is no first name, say 'Hi there,'. You would write the following:
Hi {{#if (eq [FIRSTNAME] '') }}there{{else}} {{FIRSTNAME}}{{/if}},
Replace FIRSTNAME with the Merge Tag name for your first name field.
We can use any merge tag or custom field here instead of GENDER.
Lets take it a little further...
If we wanted to say hi to the Ladies, and then Gentleman, but we also have some subscribers that do not have a gender marked against them, we could do this
{{#if (eq [GENDER] Male) }}</strong><strong>Hello Mr{{else if (eq [GENDER] 'Female') }}Hello Mrs{{else}}Hello There{{/if}}
The above example would show "Hello Mr" to an Males, "Hello Mrs" to any Females, and finally "Hello There" to anyone who hasn't got a gender set.
Nesting
As well as straight forward conditions, you can also nest statements. For example if you want to show a different greeting to men and women, but also want to show a different message to men who like shoes we could do this.
{{#if (eq [GENDER] 'Male') }}
{{#if (eq [LIKESSHOES] 'YES') }}
Hello Shoe Lover!
{{else}}
Hello Mr Non Shoe Lover
{{/if}}
{{else if (eq [GENDER] 'Female']}}
Hello Mrs
{{else}}
Hello There
{{/if}}
And Or?
The example above details what we call an IF statemement, which is going to work for a lot of situations. But what about if we want to add some slight more in depth rules. What if we we want to include everyone who is male OR everyone who is exactly 30 years of age. For this we can use an OR statement.
{{#if (or (eq [GENDER] 'Male') (eq [AGE] '30') ) }}Hello Mr{{/if}}
And now taking it a little further, what about if we want everyone who is female or OVER the age of 40...
{{#if (or (eq [GENDER] 'Female') (gte [AGE] 40) ) }}
Hello Mr
{{/if}}
You can see we have used a tag called gte above, which stands for "Greater than or Equal To". So in the example above we are saying the gender must be female, OR AGE must be greater than or equal to 40.
There are multiple "Operators" you can use here, instead of gte.. They are as follows:
gte: Greater than or equal to
lte: Less than or equal to
lt: Less than
gt: Greater than
eq: Equals
ne: Doesn't equal
And finally, you can also use the word AND instead of OR if you require multiple details to match. For example in this example we need gender to be "Male" and age to be 40
{{#if (and (eq [GENDER] 'Female') (eq [AGE] 40) ) }}
Hello Mr</strong><br>
{{/if}}
Misc Functions
Date Formatting
You can change the format of any date field by using the following...
{{formatDate CUSTOMFIELD "YYYY-MM-DD"}}
Available values are:
Value | Unit | Example |
M | Month | 1 2 ... 11 12 |
Mo | 1st 2nd ... 11th 12th | |
MM | 01 02 ... 11 12 | |
MMM | Jan Feb ... Nov Dec | |
MMMM | January February ... November December | |
Q | Quarter | 1 2 3 4 |
Qo | 1st 2nd 3rd 4th | |
D | Day of Month | 1 2 ... 30 31 |
Do | 1st 2nd ... 30th 31st | |
DD | 01 02 ... 30 31 | |
DDD | Day of Year | 1 2 ... 364 365 |
DDDo | 1st 2nd ... 364th 365th | |
DDDD | 001 002 ... 364 365 | |
d | Day of Week | 0 1 ... 5 6 |
do | 0th 1st ... 5th 6th | |
dd | Su Mo ... Fr Sa | |
ddd | Sun Mon ... Fri Sat | |
dddd | Sunday Monday ... Friday Saturday | |
e | Day of Week (Locale) | 0 1 ... 5 6 |
E | Day of Week (ISO) | 1 2 ... 6 7 |
w | Week of Year | 1 2 ... 52 53 |
wo | 1st 2nd ... 52nd 53rd | |
ww | 01 02 ... 52 53 | |
W | Week of Year (ISO) | 1 2 ... 52 53 |
Wo | 1st 2nd ... 52nd 53rd | |
WW | 01 02 ... 52 53 | |
YY | Year | 70 71 ... 29 30 |
YYYY | 1970 1971 ... 2029 2030 | |
Y | 1970 1971 ... 9999 +10000 +10001 | |
Note: This complies with the ISO 8601 standard for dates past the year 9999 | ||
y | Era Year | 1 2 ... 2020 ... |
N | Era | BC AD |
Note: Abbr era name | ||
NN | BC AD | |
Note: Narrow era name | ||
NNN | Before Christ, Anno Domini | |
Note: Full era name | ||
gg | Week Year | 70 71 ... 29 30 |
gggg | 1970 1971 ... 2029 2030 | |
GG | Week Year (ISO) | 70 71 ... 29 30 |
GGGG | 1970 1971 ... 2029 2030 | |
A | AM/PM | AM PM |
a | am pm | |
H | Hour | 0 1 ... 22 23 |
HH | 00 01 ... 22 23 | |
h | 1 2 ... 11 12 | |
hh | 01 02 ... 11 12 | |
k | 1 2 ... 23 24 | |
kk | 01 02 ... 23 24 | |
m | Minute | 0 1 ... 58 59 |
mm | 00 01 ... 58 59 | |
s | Second | 0 1 ... 58 59 |
ss | 00 01 ... 58 59 | |
S | Fractional Second | 0 1 ... 8 9 |
SS | 00 01 ... 98 99 | |
SSS | 000 001 ... 998 999 | |
SSSS ... SSSSSSSSS | 000[0..] 001[0..] ... 998[0..] 999[0..] |