Site logo

Archived topic

Google Global Site Tag (gtag.js)

5 replies · Started by Mario on October 28, 2021

Viewing posts 1–6 of 6

Hi there,
I tried to insert the Google Global Site Tag (gtag.js) from my Goggle Analytics admin panel into the header section of my website using a hook as per the advice in the documentation (I set the hook position to wp_head and to Entire Site). However, when I look at the HTML code of the website, I can see that it's actually located in the body section (after <body>) and the code itself has also changed from what I copied and pasted into the hook text box.
How do I resolve this?

Hi Leo,
I can't disable all other plugins - it is a live site. The code in line 313:
}</style></head><body class="home page-template-default page page-id-10914 wp-custom-logo wp-embed-responsive post-image-aligned-center slideout-enabled slideout-mobile sticky-menu-no-transition sticky-enabled both-sticky-menu mobile-header mobile-header-logo mobile-header-sticky no-sidebar nav-below-header separate-containers nav-search-enabled header-aligned-left dropdown-hover full-width-content elementor-default elementor-kit-7434" itemtype="https://schema.org/WebPage" itemscope> <script async src="https://www.googletagmanager.com/gtag/js?id=UA-XXXXXXX"></script> <script>window.dataLayer = window.dataLayer || [];
You can see it is in line after the </head>.

Hi Leo,
Thanks for the help.
I have made the research on my development site and found that the problem was with a plugin: Asset CleanUp Pro - Move All <SCRIPT> tags From HEAD to BODY - I have disabled.
The analytics code is bak in the head section.

No problem :)

This archived topic is closed to new replies.