Implementing Google Analytics four (GA4) property
Do you use standard Google Universal Analytics (UA) on your Jekyll Blog? If yes, then the time is ripe for you to use GA4 instead of UA property.
Why do you need to use the GA4 property?
Google has stated that it would cease processing new data in standard properties starting July 1, 2023. Yes, you have time, but don’t you want to compare Universal Analytics properties to GA4 properties? Don’t you want to import your existing data into the Google Analytics4 property?
How to set up Google Analytics4 properties?
Prerequisites
- You have a Google Analytics account.
- You have already enabled Google Analytics for your website.
Procedures
- Sign in to your Google Analytics account.
- Click the icon. The system displays three columns; Account, Property, and View.
-
In the Property column, select GA4 Setup Assistant, and click Get Started.
Note: If you have used the gtag.js (a JavaScript library) tag in your Jekyll website, GA4 offers you to Enable data collection using your existing tags. -
Click Create Property. The system displays your GA4 property name (G-xxxxxxxxxx) and a message indicating that you have successfully connected your properties.
Good to know: The setup wizard:
* Creates a new GA4 property
* Copies the name, URL, timezone, and other settings from your existing property
* Activates the enhanced measurement
* Establishes a connection between Standard Analytics and GA4 properties - Copy and save your GA4 property name for future use.
What changes do you need in your Jekyll website?
You now have a GA4 property name. Use it on your Jekyll website.
Procedures
-
Browse to the location where you have used the gtag.js (a JavaScript library) tag.
Good to know: Generally, users include the gtag.js at the head of the Default layout. Additionally, you may have placed the Google Analytics (gtag.js tag) code in your _includes folder. -
You have two options, either add the GA4 property name or update the entire Google Analytics code.
Note: If you go later, you will lose the ability to track your website data using Universal Analytics. Therefore, it is best to add the GA4 property name to your Google Analytics code. -
Add the GA4 property name to your Google Analytics code.
<!-- Global site tag (gtag.js) - Google Analytics --> <script async src="https://www.googletagmanager.com/gtag/js?id=UA-xxxxxxxxx-x"></script> <script> window.dataLayer = window.dataLayer || []; function gtag(){dataLayer.push(arguments);} gtag('js', new Date()); gtag('config', 'UA-xxxxxxxxx-x'); gtag('config', 'G-xxxxxxxxxx'); </script>
UA-xxxxxxxxx-x = Your Universal Analytics property.
G-xxxxxxxxxx = Your GA4 property.
Congratulations! You have successfully configured your Jekyll website to use Google Analytics four (GA4) property. You may need to wait for 48 hours for data to appear in your GA4 property.
If you have questions, let me know in the comments sections.