The Templates tab of Emarsys Real Time Messaging shows you all the templates currently available. Hovering your mouse cursor over the thumbnails reveals icons for viewing and editing the template, as well as creating a mail stream which uses the template.

templates_1

A template may be associated with more than one mail stream, and these are listed on the top right of the template editor. However, once a mail stream is activated it creates a snapshot of the template and uses that. This means that you can continue to work on the template without affecting the associated mail streams. Once you are satisfied with your changes, you can update the mail stream with the new changes.

Creating a Template

Basic content

All templates must include a From (name), From (email address) and Subject line. You can also define the Sender domain and Encoding.

In the text editor section, you can enter the content for the HTML and Text versions. There is no WYSIWYG editor, but you can preview the email at any time.

Transaction-specific content

You can also include content from the transaction that triggered the email. For this you need to know the field names in your website or web shop that are used to store the values. These can be added to the template content and are identified by their $$ tags. To include transaction-specific content, proceed as follows:

  1. Click Edit Fields to open the field editor.
  2. In the Available Fields pane, enter the field name exactly as it is in your web shop.
  3. Select whether to create this as a text or numeric field and click Save.

create-fields

The new field will now appear in the Assigned Fields pane for this template, and will be available for other templates as well. To assign an existing field to a template, select it in the editor and click the right-arrow, or simply double-click it.

Example

In the example below, a shipping confirmation email contains dynamic content placeholders for the customer name, item and delivery date, taken from the web shop database:

fields-example

Default field values

In the case that there might not be a value for every field in the transaction, you can specify default values to be used instead, using the following convention:

$$field_name|default_value$$

This must be done for each template individually. Please note that if no default value is specified for an empty field, this will result in an empty string (i.e. a blank space will be displayed in the email).

Rules for field names

Field names are case insensitive, so $$FIELD1$$ and $$field1$$ reference the same field.

A field name must start with an ASCII character (a-z, A-Z) or an underscore (_), which can be followed by ASCII characters and digits (0-9) and underscore. A field name must not start with 2 underscores __ .

The following field names are reserved and can not be used when creating new fields:

  • bounce_code
  • campaign_domain
  • campaign_language
  • campaign_version
  • event_time
  • external_id
  • linkname
  • mail_stream_id
  • mailid
  • onlineversion_url
  • open_tracking_pixel
  • ts
  • unsubscribe_url
  • url
  • recipient_user_agent
  • recipient_operating_system
  • recipient_device
  • recipient_ip

Note: Make sure not to use two consecutive $’s ($$) unintentionally in your template as this will always be interpreted as the start of a field reference.

Tracking pixel

The tracking pixel for checking mail opens is a transparent 1 pixel image within the HTML content, and its fetching by the mail client will be registered as an open action by the recipient. The tracking pixel can be placed anywhere in the main HTML content (not in conditions) by inserting the system field $$open_tracking_pixel$$. Then during mail sending this system field usage will be converted into the <img> tag for the tracking pixel.

If this marker is not used, the tracking pixel will be automatically placed after the opening <body> tag.

Conditional content

You can also define dynamic content which will be displayed according to the value of these fields. Proceed as follows:

  1. Click Edit Conditions to open the conditional text editor.
  2. Create and name the condition.
  3. Select the field you want to use.
  4. Select a criterion for that field value and add the conditional content.
  5. Repeat this for all the criteria you want.
  6. Define the default content which will be displayed if none of the criteria are met (‘otherwise‘).
  7. Close the conditional text editor.

The conditions are now available to drag and drop into the template content. They can be identified (referenced) by their ## tags. When the email is launched, the appropriate content will be included according to the values in the fields for that transaction.

Note: You can include both fields and other conditions in the conditional text. Make sure to use the right identifiers ($$ or ##) and write the name exactly as it is in the field or conditional text editor. If you spell the name wrong, an empty string (i.e. a blank space) will be displayed.

Example

You could define a condition called Seasons_greetings, with three cases:

  • When ‘Delivery_date contains December‘ display ‘Merry Christmas’.
  • When ‘Delivery_date contains January‘ display ‘Happy New Year’.
  • Otherwise is left empty.

Now when you add ##Season_greetings## to the bottom of your template content, all those emails sent confirming delivery in December will wish the recipient a Happy Christmas, those confirming delivery in January will wish them a Happy New Year, and the rest will show no content. You could also choose to display different images rather than text (see below).

Writing conditions

A condition can look like the following example: (EMAIL contains "@aol.com"): here, EMAIL is the field, contains is the operator and "@aol.com" is the value.

Note: In order to use a recipient field in a condition it must first have been added to the template.

Operators
  • contains – True if the field contains the specified value (text operator).
  • in – True if the field is one of the comma separated list of values.
  • < – True if the field is less than the specified value (numeric operator).
  • > – True if the field is greater than the specified value (numeric operator).
  • = – True if the field is equal to the specified value.
  • != – True if the field is not equal to the specified value.
Multiple expressions

Expressions can be combined by either and or or, e.g. (age > 24) and (country = "Austria").

Negating expressions

The result of an expression can be negated by wrapping the expression in a not() operator, e.g. not(age > 24).

Rules for condition names

A condition name must start with an ASCII character (a-z, A-Z) which can be followed by ASCII characters, underscore (_) and digits (0-9). A condition name must not start with IN….

The following condition names are reserved:

  • mailheader

Note: Make sure not to use sequences of hashes (#) in your template (for example as header or page divide) because two consecutive hashes (##) mark the beginning of a condition reference.

links

All the links in the template (this means the values of href-attributes in elements) will be tracked.

Parts of links may be persionalized, but at least the protocol part (http:// or https:// ) must be unpersionalized.

  • So <a href="http://$$link_target$$">validLink</a> is a valid personalized link,
  • whereas <a href="$$link_target$$">invalidLink</a> is not a valid personalized link