Hello again –
Quick question for you guys. I’m currently adding Google Tag Manager code to my site, and I need to add two snippets of code – one in the <head> of every page, and one immediately after the opening <body> tag.
I’m pretty sure I can use webhooks to add the code into the <head> of every page by using wp_head on every page with a position of 2 (so it’s below my GA tag). However, I’m not quite sure how to use a webhook to add the second bit of code right after the opening <body> tag. Is it possible to do this with a webhook?
Also, I’m assuming I need to put the Google Tag Manager code in the <head> below my GA tag for Google Analytics?
Thanks as always! I’ve included the two snippets of code below for reference.
– Evan
Paste this code as high in the <head> of the page as possible on every page:
<!– 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-NJHHGGJ’);</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-NJHHGGJ”
height=”0″ width=”0″ style=”display:none;visibility:hidden”></iframe></noscript>
<!– End Google Tag Manager (noscript) –>
GP Premium 1.7.8