Hello!
I’ve been browsing the forums looking at guides / instructions for implementing Google Tag Manager to the latest version of X. I’ve tried following a bunch of different tutorials and they either don’t work, are badly written, or seem to be outdated.
I’m currently running the latest version of X w/ a Child Theme setup. I’ve been trying to add code to my functions.php and it’s partially working.
For Google Tag Manager, you need both a snippet of code in the Body and one in the Header. All the posts on these forums don’t reference/address both of these. Here are the tags:
Paste this code as high in the <head> of the page as possible:
<!-- Google Tag Manager -->
<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','GTM-TAGIDHERE');</script>
<!-- End Google Tag Manager -->
Additionally, paste this code immediately after the opening <body> tag:
<!-- Google Tag Manager (noscript) -->
<noscript><iframe src="https://www.googletagmanager.com/ns.html?id=GTM-TAGIDHERE"
height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript>
<!-- End Google Tag Manager (noscript) -->
I tried following a couple guides and using what I could find in the forums but it doesn’t appear to be working.
Content of Framework.php
for Child Theme: https://hastebin.com/ometisiyig.xml
Content of _HEADER.php
for the Child Theme: https://hastebin.com/izakawaxoy.cs
Any help would be appreciated!
Thank you.