- 23 Nov 2023
- 1 minute read
- Print
- DarkLight
- PDF
How-To: Add GTM container script code to your Branding Template
- Updated 23 Nov 2023
- 1 minute read
- Print
- DarkLight
- PDF
You can include your GTM container 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.
![image(124).png](http://cdn.us.document360.io/cd8ea7a6-07f3-4846-a554-627ac016d3e3/Images/Documentation/image(124).png?sv=2022-11-02&spr=https&st=2024-09-08T01%3A14%3A48Z&se=2024-09-08T01%3A24%3A48Z&sr=c&sp=r&sig=S0OY0Qvnsuv2r2yOH4qk1qW%2BaoyBx%2F%2FbqXxxi3b1q9s%3D)
Find the tag near the top of the file (highlighted in the sample screenshot) and place your GTM just above the closing tag. In the example below, this would be above line 20 (the contents inside the will vary from template to template - just concentrate on finding the closing tag).
Copy the code you received from the GTM installation instructions or your Marketing folks, and paste the full script into the file. You will see something like this:
Note the 'red' code highlight (in the example above on line 22) indicating that there is malformed code that cannot be successfully parsed. If you attempt to save this file, you will encounter a browser error stating something like "An error occurred while parsing EntityName. Line 22, position 42.".
The Slate-based file editor is expecting valid XHTML code. Some characters are reserved in HTML; the '&' character is one of them. Character entities are used to display reserved characters in HTML. In the original script '&' merely needs to be properly escaped using the proper HTML entity code '&' . Once you type this into the file, the 'red' markup will disappear:
Save the file (at the bottom of the pop-up window) and you are done.
For more information on GTM and the default version of the script see: https://developers.google.com/tag-manager/quickstart.