Page 1 of 1

Google Analytics add

Posted: Wed Jun 05, 2019 4:19 am
by 2fralph
Struggling to add in my Google analytics code at the bottom of </head>

It says this

Syntax error in template "template:appdata;tmp_template" on line 21 "function gtag(){dataLayer.push(arguments);}" - Unexpected ".", expected one of: "}"
No content blocks defined in template

This is the piece of code that google has given me and it doesn't like it?
Anyone have any thoughts?

Cheers

Re: Google Analytics add

Posted: Wed Jun 05, 2019 12:13 pm
by scooper
CMSMS thinks anything surrounded by braces is a Smarty template tag and will try to process it.

You can either let Smarty know not to try parsing the code by wrapping the javascript in {literal} {/literal} tags, or you can add a space immediately after the opening brace so that Smarty doesn't think it's a tag.

Code: Select all

{literal}
function gtag(){dataLayer.push(arguments);} 
{/literal}
or

Code: Select all

function gtag(){ dataLayer.push(arguments); }
s.