Archived topic
Hook Element Priority
3 replies · Started by Ana on September 8, 2022
Hello,
My Google analytics G4 tag is not tracking correctly. The UA analytics is working fine, and the script shows at the very beginning of the head.
I added the G4 tag as a hook element in wp_head. However, when I inspect any page, the script shows at the very bottom of the head, after all the ad scripts. Accordingly, not all pages are tagged in G4, and not tracking all page hits.
Which priority should I set to make it appear higher? or is there anything else I need to do?
Here's the site:homemadepizzapro.com and the tag.
Thanks in advance for your help.
<!-- Google tag (gtag.js) -->
<script async src="https://www.googletagmanager.com/gtag/js?id=G-NHV97ZZXJW"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'G-NHV97ZZXJW');
</script>
Hi Ana,
In general, lower priority should place a code higher. Try a priority of 1.
Hello,
I changed the priority to 1 but nothing changed. The GA4 script is still at the end after all ads. Consequently, GA4 is not tracking real-time activity correctly. Please let me know what else I can do. Thanks.
Hi there,
you can set the priority to 0 zero - if there are other elements still appearing before that, then how were those added to the site ?