Site logo

Archived topic

Where to put Google Analytics code?

41 replies · Started by Heath on May 30, 2021

Viewing posts 1–15 of 42

I have the GP Premium and currently put the code in a hook in the wp_head with the entire site checked. I'm not sure this is where I need to put it as numbers over the last several days don't seem accurate. Is that correct?

Hmm. My analytics is not working.

Hi Heath,

Can you share the script you're trying to add? (use the private information text field)

I've checked the site and I don't see the usual google analytics script on the <head> of your site.

Note: Google takes time to reflect the data. Even when the script is properly loaded, it takes time to display things right. :)

This is I guess Google Analytics 4 code. This is the exact code that analytics says to add in the header.

Thanks.

I've rechecked again and found it as shown here - https://share.getcloudapp.com/v1uYvg5Z

I'm not sure if this is the right script, but if it is, then we should give Google a few hours to get things going as this isn't something instant. It will take Google Analytics sometime before showing your stats.

Tip: If you find this lacking, consider using a plugin. Check this - https://www.wpbeginner.com/beginners-guide/how-to-install-google-analytics-in-wordpress/ (MonsterInsight)

Yeah I seems to be at least partially working at the moment. Thanks for checking.

No problem. Glad to be of any help. :D

Just to let you know, the numbers seemed off again. Out of curiosity, I switched back to my old theme and the analytics are flowing like a charm so I'm not sure what it is about GP that I'm not able to get my analytics in there right.

Hi there,

looks like you're running Google Tag Manager - which requires two codes, the first code provided gets hooked into the wp_head - the second code they provide should be hooked into the wp_body_open

Also ensure and Plugin and server side caches are cleared after making these changes, this will ensure the updated page gets served up for the analytics scripts to fire.

Yeah. I was doing that. Unless I had something off but I triple checked.

Looks like you have another theme installed on the site.
I ran a gachecker test on the site and the vast majority of the URLs failed to display a valid GA or GTM Tag.
Then i took a closer look at some of the failed URLs eg.

https://theprospecttimes.com/tag/joey-gallo/

And this has 2 x instances of gtag/js installed into <head> which is why that one failed.

So i can only assume you have another plugin or function that is adding GA scripts ... considering this is not even on the GP theme.

I just ran that as well and have no clue what would cause that. I dont have any plugins adding any GA code.

Any custom functions in say the Code Snippets plugin ?

I would say yes but that plug-in isn't active. I'm not even sure I have that even as an inactive plug-in. This is bothering me because I really want to have GP as my theme. Now I'm not even sure if the numbers I am seeing are accurate.

This archived topic is closed to new replies.