End user System Administrator Jahia 7.3 Jahia 8 Legacy

How to embed the the Google Tag Manager


What is the best way to embed the Google Tag Manager into my site?


To install the Google Tag Manager, you need to insert some code in all of your pages. A part has to be as high in the <head> of the page as possible, and the other immediately after the opening <body> tag.

You can do it directly in the main JSP of your template set, or you can use the module addStuff.

To install this module deploy it from the administration then activate the module on your site, go to edit mode and right-click on the site from the left panel, then go to Option and click on the "Add stuff in your HTML code (only for preview/live mode)".


Then you can copy the generated this snippet in the top of the HEAD (please use the real code from the GTA main site -> Admin -> Install Google Tag Manager). This looks like this:

<!-- Google Tag Manager -->
new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],
<!-- End Google Tag Manager -->

and this code on the top of the BODY:

<!-- Google Tag Manager (noscript) -->
<noscript><iframe src="https://www.googletagmanager.com/ns.html?id=GTM-M2LQKQL"
height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript>
<!-- End Google Tag Manager (noscript) -->

The AddStuff module only inserts the code in preview and live mode.