You have to upgrade Universal Analytics to GA4 until July 1, 2023.
According to Google:
Google Analytics 4 is an analytics service that enables you to measure traffic and engagement across your websites and apps.
Here is how I upgraded my website.
STEP 1 – Go to Google Analytics
Go to https://analytics.google.com/ and log in with your Google Account.
STEP 2 – GA4 Setup Assistant
Click on the “Admin” link (lower left) and select your UA property (if more than one).
Locate the “GA4 Setup Assistant” link and follow the wizard:
Set up your GA4 tracking code (see instructions below).
STEP 3 – Check it works!
To verify that data is being collected, check the Realtime report for activity (from the Reports menu).
How to set up the GA4 tracking code in WordPress
Without plugin
In your functions.php
file of your child theme:
function wp_google_analytics() { ?>
<!-- Begin Google Analytics 4 Code (GA4) -->
<!-- Google tag (gtag.js) -->
<script async src="https://www.googletagmanager.com/gtag/js?id=G-XXXXXXXXXX"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'G-XXXXXXXXXX');
</script>
<!-- End Google Analytics 4 Code (GA4) -->
<?php
}
add_action( 'wp_head', 'wp_google_analytics' );
Remember to replace G-XXXXXXXXXX with your MEASUREMENT ID.
Using plugin
Check out the available plugins.
Where are my Universal Analytics Views?
If you have created Views in Universal Analytics (UA) properties, these are not available in GA4. GA4 does not support Views. Use Report filters to create something similar to your old Views.
What about subdomains?
You can put the same tracking code in subdomains (if any). Google Analytics 4 will handle this situation automatically.
Regarding Historical Data
Google decided to delete all historical Universal Analytics data beginning on January 1, 2024. If you want to save some of them, consider using Google Analytics Spreadsheet Add-on.
Can chatGPT help you to set up GA4?
Well, read this post.
Reference
- [GA4] Add a Google Analytics 4 property (to a site that already has Analytics)
- How to migrate to Google Analytics 4: A step-by-step guide
- [UA→GA4] Comparing metrics: Google Analytics 4 vs Universal Analytics
- [GA4] Set up cross-domain measurement
Useful Video
Further Configuration
Entrepreneur | Full-stack developer | Founder of MediSign Ltd. I have over 15 years of professional experience designing and developing web applications. I am also very experienced in managing (web) projects.