XF 2.1 Installing Google Tag Manager in Xen Foro

niros_1234

Member
Hey, guys

I am trying to install google tag manager on my forum.

Google tag manager has two snippets of code that need to be inserted on every page:

a. one that goes in the header
b. one that goes in the body.

I tried to do this by modifying the PAGECONTAINER of the Default Style (that is the only style installed)

I added this after the <head>

Code:
<xen:comment><!-- Google Tag Manager --></xen:comment>
<script>(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':
new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],
j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=
'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);
})(window,document,'script','dataLayer','____PRIVATE______');</script>
<xen:comment><!-- End Google Tag Manager --></xen:comment>

I added this after the
</head>
<body data-template="{$template}">

Code:
<xen:comment><!-- Google Tag Manager body code --></xen:comment>
<noscript><iframe src="https://www.googletagmanager.com/ns.html?id=____PRIVATE___"
height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript>
<xen:comment><!-- End Google Tag Manager --></xen:comment>

Then in order to check if the installation is OK, I installed the Google Tag Assistant Extension in Chrome and I get the following errors.

GTM Java Script code not found as a direct child of the <head> tag
GTM No script code not found. either missing or not in the <body>

What I am doing wrong?

Capture.webp
 
Top Bottom