Merge tags help you to insert dynamic information into 

  • campaigns,
  • subjects,
  • URL links.

You enter the merge tag but subscriber receives the dynamic information instead, because the merge tag is replaced by the correct information at the moment of the distribution.

Basic formatting

Delimiters

  • {% ... %} executes statements (e.g. for-loops)
  • {{ ... }} prints the result.

Fields, filters, functions

  • Pipe (|) separates filter from a variable. Optional argument can follow in parentheses. 
  • Functions are called by their name followed by parentheses (()) and may have arguments.

See the list of supported merge tags

Fields

All fields have return value string. General structure is 

{{ object.attribute }} or {{ object.embedded_object.attribute }} etc.

Campaign

Currently there is only one merge tag related to campaigns, it is

{{ campaign.guid }}

 which inserts the UUID id of the campaign.

Company

As a company merge tags can be used

{{ company.name }}

to insert company name and

{{ company.vat }}

as a company's VAT number.

Subscriber

There is several subscriber information, that can be entered using the merge tags:

{{ subscriber.contact.email }}

to insert subscriber's email,

{{ subscriber.contact.firstName }}

to insert subscriber's first name,

{{ subscriber.contact.lastName }}

to enter subscriber's last name.

Filters

All filters have return value string. General structure is

{{ object|filter("optional_formatting_argument") }}


Following examples uses this data sample

{
        "link": "www.google.com",
        "now": "2012-04-23T18:25:43.511Z",
        "id": 15,
        "hero": {
            "name": "Thanosus",
            "address": {
                "planet":"Titan"
            }
        },
        languages: ["eng", "cs", "fr", "de", "hu"]
}

Date and time

Merge tags can be used to provide time and date records.

{{ now|date("yyyy-MM-dd") }}

returns formatted date according to the optional argument - in you case the result will be "2012-04-23". If pattern is not defined (parentheses are empty), system will use client's default time format from Clever AIM settings. Make sure, the month symbols are capital MM.

{{ now|dateTime("yyyy-MM-dd hh:mm") }}

does the same, but shows both date and time (returns "2012-04-23 18:25"). Again, if argument in parenthesis is missing, default system setting will be used.

{{ now|time("hh:mm") }}

on the other hand displays only time (according to the argument or default system setting) - returns "18:25".

Get

"Get" allows you to call particular objects or their attributes. Parameters can be one to many and can be integer (representing index of value in array) or string (representing key of value). Indexing starts from 0 (first value is under index 0, second under index 1, etc.)

{{ languages|get(1) }}

calls the second value in array languages (in our case returns "cs").

{{ languages|get(1, 3, 4) }}

calls the second, fifth and sixth value from the same array (returns "cs", "de" and "hu") .

{{ hero|get("name") }}

calls the name attribute (returns "Thanosus").

{{ hero|get("name", "planet") }}

calls the name and address attribute (returns "Thanosus" and "Titan").

Default

Default filter replaces merge tag if the preceding field is empty.

{{ hero|get("address")|default("N/A") }}

If the preceding field "address" is empty, this filter defines the default value for it.

Lower and upper

These two filters convert all letters to lower or upper case.

{{ hero.address.planet|lower }}

converts all letters to lower case (returns "titan"),

{{ hero.address.planet|upper }}

converts all letters to upper case (returns "TITAN").

Join

allows you to glue values from an array together. Default Glue is empty string "" but can be defined in the optional argument.

{{ languages|join(", ") }}

will display all values from the array separated by ", " - in our case it will return "en, cs, fr, de, hu".

URL Encode

This filter encodes a given string as URL segment or an array as query string.

{{ link|url_encode }}

takes the value from "link" and formats it as an URL address - showing "www.google.com" as an hyperlink.

Function

URL function

The URL function simply converts inserted link into a trackable one.

{{ url("https://www.google.com") }}

is the simplest type: "url" (name of the function) is followed by one URL address in parentheses. When campaign with this merge tag is being send the url function will be replace with

<a href="https://www.google.com">https://www.google.com</a>

as "a href" is trackable.

{{ url("https://www.google.com", "My title") }}

is more advanced version which gives the link a custom title and in the email it is replaced with

<a href="https://www.google.com">Custom title</a>

You can use variables in this function as well, so

{{ url(link, "Custom title") }}

will be replaced by 

a href="{{ link }}">Custom title</a>

and will link to the address that is stored in the "link" variable.

Unsubscribe and Webview functions

These two functions should not be inserted simply in the text field, but only as a hyperlink URL (without the "http://", just the merge tag). So create a hyperlink with corresponding text and as the URL address insert

{{ unsubscribeLink() }}

to create an unsubscribe link, or

{{ webviewLink() }}

to redirect to the webview version of the campaign.

Did this answer your question?