Smarty error: 'unrecognized tag...'

If you get the unrecognized tag... Smarty error after adding JavaScript code (tracking code for example) to a template, most probably the inserted JavaScript contains { and } tags. { and } are the Smarty delimiters, so Smarty falsely wants to interpret the JavaScript code in the template.

To avoid the error:

  1. Open the template where you added the code.
  2. Enclose the JavaScript code in a {literal}...{/literal} block to prevent Smarty from parsing it:
    {literal}
    your JavaScript code
    {/literal}
  3. Save the file.

Noticed an error in the article or it is not clear enough? Any suggestions to improve it? Please let us know by filling in the feedback form. Click here.