How-To: Add Google's Global site tag (gtag script) code to your Branding Template

You can include your Gtag script in your Slate branding template by going to the 'shared' folder in the File Editor. Find the main build xslt file of the branding template. 

Click on the /shared/build.xslt to pop up the 'Edit File' view.

Find the <head> tag near the top of the file (highlighted in the sample screenshot) and place your Gtag script above the closing </head> tag. In the example below, this would be above line 20 (the contents inside the <head> will vary from template to template - just concentrate on finding the closing tag).

mceclip0.png

mceclip2.png

Copy the code you received from the Gtag installation instructions or your Marketing folks, and paste the full script into the file. You will see something like this:

mceclip0.png

If you attempt to save this file, you would encounter a browser error stating something like "'src' is an unexpected token. The expected token is '='. Line 17, position 15.".

The Slate-based file editor is expecting valid XHTML code. In this case, it is important to remember that in XHTML, attribute minimization is forbidden and attribute values must always be quoted. Make the change as indicated below (using, of course, your own UA property ID). (see this external article for more details on XHTML).

<script async="async" src="https://www.googletagmanager.com/gtag/js?id=UA-xxxxxxx-x"></script>

mceclip1.png

Save the file (at the bottom of the pop-up window) and you are done. 

mceclip5.png

Was this article helpful?
3 out of 4 found this helpful