Site logo

[Resolved] Google Universal Analytics code and Google Analytics 4 code

Home Forums Support [Resolved] Google Universal Analytics code and Google Analytics 4 code

Home Forums Support Google Universal Analytics code and Google Analytics 4 code

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #2070995
    Don

    Good Morning,
    I was wondering how to add both the older Google Universal Analytics code and the newer Google Analytics 4 code into the GeneratePress theme so they are both working correctly?
    Thanks!

    #2071031
    David
    Staff
    Customer Support

    Hi there,

    this doc explains how to create a page tag for a site that is already Universal analytics:

    https://support.google.com/analytics/answer/9744165?hl=en#zippy=%2Cif-you-add-your-tag-using-google-tag-manager%2Cif-you-are-using-a-website-buildercms

    The resulting code, to the best of my knowledge, needs to go in the <head> of your site.
    If thats the case – then you can add it using a Hook Element:

    https://docs.generatepress.com/article/hooks-element-overview/

    And select the wp_head hook.
    And set your Display Rules to Entire Site or just the pages you want it to fire on.

    #2071047
    Don

    Hello,
    I already have both the Google Universal Analytics code and the Google Analytics 4 code setup on Google and have been using them for over a year. I changed theme to GeneratePress, my old theme had a place to install both tracking codes. I didn’t see a way to add both codes to GeneratePress so I connected both google codes together and used the method you described to add the code into GeneratePress, But it not working. So is there a way to add the two tracking codes separately into GeneratePress?
    Thanks.

    #2071050
    Don

    Hello,
    OK, I reread the link you send and it looks like I just add both codes to the head. Sorry for wasting your time!
    Thanks.

    #2071285
    David
    Staff
    Customer Support

    Thats correct use the wp_head hook to achieve that in the Hook Element.

    Glad to be of help

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