- This topic has 12 replies, 5 voices, and was last updated 3 years, 5 months ago by
Ying.
-
AuthorPosts
-
November 26, 2021 at 2:18 am #2022869
Clare
At least twice now the gooogle analytics code has disappeared from my head theme code. Why is this? I’m not making any updates to the theme or WordPress versions other than what is happening automatically. Thanks
November 26, 2021 at 6:05 am #2023464David
StaffCustomer SupportHi there,
how has the GA code been added to the site ?
January 24, 2022 at 2:26 am #2091449Clare
Hi David. This has happened again – it seems to happen every couple of months. I have added it again to the theme header. Any idea why it keeps dropping off?
January 24, 2022 at 4:43 am #2091548David
StaffCustomer SupportIf you’re editing the parent Themes files then the header.php will be overwritten when the Theme is updated.
This article explains how to add google tag manager ( the same applies for Google Analytics ) to your site:
https://docs.generatepress.com/article/implement-google-tag-manager/
February 3, 2022 at 2:31 pm #2104447Clare
Thanks David. I’m not editing anything in Theme editor but I am going into customise and tweaking things like heading settings – size, weight etc. Would this cause GA to fall off?
February 3, 2022 at 9:56 pm #2104677Elvin
StaffCustomer SupportHi Clare,
Let’s settle this for the script so it NEVER happens again.
Can we change how the script is being added?
I suggest using a Hook element for this.
The setup would be something like this – https://share.getcloudapp.com/p9uXZw5x
And on its display rule tab. Set the Display Rule Location to “Entire site”.
This way, the GA won’t be messed up even if the theme updates.
April 11, 2022 at 3:48 pm #2185651Clare
Hi Elvin and David
Just coming back to this. I’ve followed your instructions Elvin and also the first part of the instructions on the page David gave above, but I can’t find a second lot of code on my GA for the second part on David’s page. Am I supposed to add that in also and if so where do I find the code? Thanks
April 11, 2022 at 9:05 pm #2185771Fernando Customer Support
Hi Clare,
Here is an article by Google with regards to this: https://developers.google.com/tag-platform/tag-manager/web
It says that it’s in the Google Tag Manager – Workspace. As per this article, you’ll need to add that as well.
It may be helpful to reach out to their support/community as well with regards to this: https://support.google.com/tagmanager/community?hl=en
Hope this helps! 🙂
April 11, 2022 at 10:28 pm #2185804Clare
Hi Fernando
So I need to add that Google Tag Manager code just to get Google Analytics to stick on my site? (see all previous comments on this post).
April 11, 2022 at 10:48 pm #2185813Fernando Customer Support
Yes, you would need it as mentioned in the link above. You could use a Hook Element and hook it as such: https://docs.generatepress.com/article/implement-google-tag-manager/#:~:text=The%20second%20block%20of%20code%20should%20look%20similar%20to%20this%3A
See: https://support.google.com/tagmanager/answer/6103696?hl=en#zippy=
Hope this clarifies. 🙂
April 12, 2022 at 5:20 am #2186171Fernando Customer Support
Hi Clare,
Just a follow up. To be sure, I tried adding Google Analytics on my personal site to see if anything has changed.
You’re correct. There’s only one tag for Google Analytics specifically. I followed this specific article and I was able to make it work: https://www.wpbeginner.com/beginners-guide/how-to-install-google-analytics-in-wordpress/
Here is a screenshot of it working on my site after adding the Global site tag code on my header: https://share.getcloudapp.com/NQuNjxQn
To reiterate, you only need this code: https://www.wpbeginner.com/beginners-guide/how-to-install-google-analytics-in-wordpress/#:~:text=you%20click%20the%20%E2%80%98Global%20site%20tag, and couple of other steps shown in the article to make Google analytics work.
Hope this clarifies. 🙂
April 13, 2022 at 2:56 pm #2188094Clare
Hi Fernando
That document is very dense and I’m a bit lost in it to be honest. Are you saying to simply add the GA code into the header section in the theme editor? If so that is what I did originally and it keeps dropping off every time the theme is automatically updated..
I’ve added the first lot of code into the hook as Elvin suggested. Do I need to do anything else?
Thanks
April 13, 2022 at 3:01 pm #2188099Ying
StaffCustomer SupportAre you saying to simply add the GA code into the header section in the theme editor?
NO, please add the code via a hook element.
I’ve added the first lot of code into the hook as Elvin suggested. Do I need to do anything else?
That should be good.
-
AuthorPosts
- You must be logged in to reply to this topic.