How to Upgrade Universal Analytics to GA4 Step by Step

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:

How to Upgrade Universal Analytics to GA4 Step by Step
GA4 setup assistant
How to Upgrade Universal Analytics to GA4 Step by Step
Create new property
How to Upgrade Universal Analytics to GA4 Step by Step
New property settings
How to Upgrade Universal Analytics to GA4 Step by Step
New property created
How to Upgrade Universal Analytics to GA4 Step by Step
Select Data Streams
How to Upgrade Universal Analytics to GA4 Step by Step
Get instructions for the GA4 tracking code
How to Upgrade Universal Analytics to GA4 Step by Step
GA4 tracking code
How to Upgrade Universal Analytics to GA4 Step by Step
Locate your new property

Set up your GA4 tracking code (see instructions below).

How to Upgrade Universal Analytics to GA4 Step by Step
Enjoy your new property!

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

Useful Video

Further Configuration