mistake
|
explanation |
Mixing old
$ or%% personalization within ESL |
These variables do not mix. They are handled by two different services and Emarsys Marketing Platform will either print the placeholders in the email or cancel the email. On the same note, placeholders, variables, and scripting used in other platforms (SFMC, Shopify, Magento, etc.) will break ESL and cancel the email. You must remove each and every instance. |
Using a single= instead of== |
In general, you will only every use= for setting a variable and== to check a value or string. |
Skipping a reference to the "global" object in JSON | If it some data is inside the “global” object, you must reference it in ESL.{{event.ordertotal}} instead of{{event.global.ordertotal}} is incorrect if inside of the "global" object |
ESL/Twig is case sensitive | {{event.global.orderTotal}} is a different variable than {{event.global.ordertotal}} |
With the exception of variables and values, you should exclusively use lowercase | Incorrect:{% if contact.1111 == 'Family' AND contact.2222 == 'Other' %} Incorrect: {% IF contact.1111 == 'Family' and contact.2222 == 'Other' %} Incorrect: {% if CONTACT.1111 == 'Family' and CONTACT.2222 == 'Other' %} Correct: {% if contact.1111 == 'Family' and contact.2222 == 'Other' %} |
Inconsistent JSON structure | If you reference JSON via ESL without checking for the existence of it first, that variable must ALWAYS exist regardless of whether it is needed. If it is not in the JSON, that email will not be sent due to missing content. |
Usually indicated by a large number of emails cancelled for "No Content" | |
Calling an undefined variable | Just because another system may reference order by{{orders.lastorder.price}} , does not mean ESL will. With the exception of custom variables and variables inside of an array that you are looping, you are limited to using variables that start with the following:{{contact...}} {{event...}} {{rds...}} |
Adding unnecessary spaces, extra words, or omitting spaces in statements | {% end foreach %} instead of{% endforeach %} {% else if %} instead of {% elseif %} {% end if %} instead of {% endif %} {% endelseif %} instead of {% endif %} {%if contact.1111 == 'Family'%} instead of {% if contact.1111 == 'Family' %} This will not necessarily break functionality, but it will break syntax highlighters and can cause confusion. |
Differences betweenif ,elseif , andelse |
In anif statement, the only mandatory pieces are{% if foo == 'bar' %} and{% endif %} .elseif andelse are always optional but useful.if is your opening condition. For everyif , there must be a closingendif . It can be nested inside anotherif but both must eventually be closed.elseif is used exclusively for checking another condition after the previous one has failed. If you do not have a second condition to check, you should be usingelse .{% elseif %} is invalid. It should never be used without a precedingif and the precedingif must not be already closed withendif .else is your fallback. If none of the preceding conditions are true,else will be used instead. It is optional. If you do not want to set a fallback, you do not need to useelse . The natural behavior ofif is to not use a fallback. |
Forgetting to use quotations when referencing a string | Strings are exact. In order to use them or check them, you must use single or double quotations surrounding them. |
Using {{ and {% interchangeably | Incorrect:{{ endif }} Correct: {% endif %} Incorrect: {% contact.1111 %} Correct: {{contact.1111}} {{...}} should always be used to print variables from JSON, RDS, contact table, etc.{%...%} should always be used for statements or logic namely:{% if... {% foreach... {% set... When referencing a variable inside of a statement, you do not need {{…}} since you are not printing the variableCorrect: {% if contact.3 %} Incorrect: {% if {{contact.3}} %} |
Common mistakes
Was this article helpful?
0 out of 0 found this helpful