Site logo

[Support request] Why does the google analytics code keep disappearing

Home Forums Support [Support request] Why does the google analytics code keep disappearing

Home Forums Support Why does the google analytics code keep disappearing

Viewing 13 posts - 1 through 13 (of 13 total)
  • Author
    Posts
  • #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

    #2023464
    David
    Staff
    Customer Support

    Hi there,

    how has the GA code been added to the site ?

    #2091449
    Clare

    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?

    #2091548
    David
    Staff
    Customer Support

    If 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/

    #2104447
    Clare

    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?

    #2104677
    Elvin
    Staff
    Customer Support

    Hi 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.

    #2185651
    Clare

    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

    #2185771
    Fernando
    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! 🙂

    #2185804
    Clare

    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).

    #2185813
    Fernando
    Customer Support
    #2186171
    Fernando
    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. 🙂

    #2188094
    Clare

    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

    #2188099
    Ying
    Staff
    Customer Support

    Are 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.

Viewing 13 posts - 1 through 13 (of 13 total)
  • You must be logged in to reply to this topic.