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.
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
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.
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:
- Click Edit Fields to open the field editor.
- In the Available Fields pane, enter the field name exactly as it is in your web shop.
- Select whether to create this as a text or numeric field and click Save.
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.
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:
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:
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:
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.
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
You can also define dynamic content which will be displayed according to the value of these fields. Proceed as follows:
- Click Edit Conditions to open the conditional text editor.
- Create and name the condition.
- Select the field you want to use.
- Select a criterion for that field value and add the conditional content.
- Repeat this for all the criteria you want.
- Define the default content which will be displayed if none of the criteria are met (‘otherwise‘).
- 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.
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).
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.
- 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.
Expressions can be combined by either and or or, e.g. (age > 24) and (country = "Austria").
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:
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.
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.
<a href="http://$$link_target$$">validLink</a>is a valid personalized link,
<a href="$$link_target$$">invalidLink</a>is not a valid personalized link