ESL is a genuine scripting language. It lets you personalize your content based on external factors, opposed to the standard personalization options, where you populate email content based only on internal contact database fields.
ESL is specifically for people with a working knowledge of coding HTML.
ESL is a twig-based language which is enhanced with a couple of Emarsys-specific code elements. Learn more about how twig works in ESL here.
Here are a couple of examples for Emarsys-specific code elements:
1. The foreach
tag
The foreach
tag works only on arrays, and is used to loop through each key-value pair in an array.
- The
foreach
tag iterates through a set of items and executes all the commands that are inside theforeach
tag and refers to the items - For example, if you have a list of stores from which you want to display only 3 of them, and you want to display name, excellence, and city, you can include this within the
foreach
tag and it will execute accordingly:
{% set shops = [{'name': 'Best shop', 'city': 'London'},{'name': 'Second Best shop', 'city': 'New york'},{'name': 'Third Best shop', 'city': 'San Francisco'},{'name': 'Fourth Best shop', 'city': 'Las Vegas'},{'name': 'Fifth Best shop', 'city': 'Budapest'}] %}
{% foreach item in shops limit 3 %}
{{ item.name }}
{{ item.city }}
{% endforeach %}
This is how it will be rendered for the contact:
2. Localized Date filter
You can format the date based on a certain country’s specific date format with the following code snippet:
{{ 'now' | localized_date('en','dd.MM.yyyy') }}
This is how it looks in the email template editor:
And this is what the contact will receive:
3. Localized time filter
If the target country has a different time format, use the the Localized time filter:
{{ 'now' | localized_time('de','HH.mm.SS') }}
This is how it looks in the email template editor:
And this is what the contact will receive:
4. Localized date and time
Localized date and time: This will combine the above 2 data:
{{ 'now' | localized_datetime('en','full') }}
This is how it looks in the email template editor:
And this is what the contact will receive:
5. Required filter
The required
filter makes sure that in case of a missing data field the campaign is not sent with an empty placeholder, for example:
{{ contact.label.46 | required }}
Here, contact.label.46
will display the value from the Single-choice salutation data field. After the pipe character there is the required tag that indicates the purpose of this filter.
This is how it looks in the template:
This is how it looks in the email when the contact receives it:
If there is no value at the contact data field that has the required filter, you won’t be able to preview the campaign, as the data cannot be populated.
To learn more about the formatting of ESL, click here.
Video script:
Hello, in this video you will learn the basics of the Emarsys Scripting Language, or as we call it ESL. This is an introductory video aimed at all Emarsys users - even those who have never written code before.
Simply put, the Emarsys Scripting Language lets you create dynamic content in your campaigns. Although Emarsys already provides out-of-the-box personalization variables, conditional text, and block targeting solutions, with ESL you build your own personalization rules, freeing you completely from any technical dependencies.
You can create rules based on various data sources. This can be contact data, like birth date, business-specific data, such as particular product information from your relational database or any external values, like additional customer data that you don’t store in the Platform. So, the customization of your content becomes easy and fully automated with ESL.