Where to add Google Tag Manager without plugin?
-
I would like to add the two pieces of Google Tag Manager code but the places I have put them have lead to the code not appearing in the source code.
Currently I have a functions.php in my child theme folder. So I add this bit of code at the bottom of this page:
<!– Google Tag Manager –>
(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-5JCJVCP’);
<!– End Google Tag Manager –>Then, I add this code:
<?php body_top(); ?>In between these two:
<body <?php body_class(); ?>>
<div id=”bodyContainer”>All of this is in my header.php file.
Finally I add this to my functions.php, again in my child theme:
<!– Google Tag Manager (noscript) –>
<noscript>https://www.googletagmanager.com/ns.html?id=GTM-5JCJVCP</noscript>
<!– End Google Tag Manager (noscript) –>But after all that, nothing shows up in the source code.
What did I do wrong? I even moved the edited header.php file from my main theme folder into the child theme.
I followed these steps:
How to manually add Google Tag Manager to a WordPress website
The blog I need help with is: (visible only to logged in users)
-
“The blog I need help with is mohammadfahadcom.wordpress.com.” No this is the not the blog I need help with. Idk how this bit got into my original question
- The topic ‘Where to add Google Tag Manager without plugin?’ is closed to new replies.