Archived topic
Installing New Tracking ID For Google Analytics 4
7 replies · Started by Luke on January 18, 2023
Hello
I want to install new tracking ID on my blog for Google Analytics (you know GA4).
I installed my old ID using All In One SEO Pack plugin, but I'm not sure how to do it now. Of course I don't want to switch to using GA4 right now, I still want to be using Universal Analytics, but I know that both of them can work simultaneously and they don't interfere with each other.
When I'm using Generate Press is there a better way to install this code than using All In One SEO plugin? Can you recommend me something?
Hi Luke,
You can use a Hook for this.
Basically, you just need to add your GA4 code through a Hook Element. Conceptually, the process would be the same as it is for GTM: https://docs.generatepress.com/article/implement-google-tag-manager/
This is one approach to do it through GeneratePress without using a third-party plugin.
OK, when I clicked the link the instructions say to do this:
Go to Appearance > Elements and click “Add New”.
From the Element dropdown list, choose “Hook”.
Copy and paste the your own code into the content area.
Under Settings tab, select wp_head in the Hook dropdown list.
Under Display Rules tab, select Entire Site in the Location dropdown list.
Click the Publish button then we are half way done.
Then below I see similar instructions:
Go to Appearance > Elements and click “Add New”. From the Element dropdown list, choose “Hook”.
Copy and paste the your own code into the content area.
--- Does it mean I'm supposed to do the same thing twice?
What about the 2 blocks of codes? Do I need to copy and paste them somewhere?
I've just noticed that the GA code appeared in the left upper corner of my site on the Homepage. I think I'm doing something wrong!
Hi there,
in your GA account - copy the Global site tag (gtag.js) script.
in WordPress -> Appearance > Elements -> Add a New Element -> Hook.
Paste in your script into the text area.
Set the Hook element to the wp_head
Set the Display Rules.
Thats all that is required for Google Analytics.
The 2 part method in that doc is only required if you're using Google Tag Manager.
You can read more here on GTM and GA:
https://www.searchenginejournal.com/google-tag-manager-ga4-guide/396169/
OK, I'm in the Display Rules tab now.
Should I choose Entire Site in the Location?
I suppose I don't have to do anything with Exclude and Users?
Set it to the Entire Site.
And leave the other options alone :)
You should sticky this!
I think we need to update our docs lol
I must say Google could make this kind of change a little clearer ... i had to treble check it :)