Archived topic
Google Universal Analytics code and Google Analytics 4 code
4 replies · Started by Don on January 6, 2022
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!
Hi there,
this doc explains how to create a page tag for a site that is already Universal analytics:
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.
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.
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.
Thats correct use the wp_head hook to achieve that in the Hook Element.
Glad to be of help
