How to switch from WordPress to Google Analytics 4 – complete guide
Looking for the easiest way to set up Google Analytics 4 on WordPress? 😎
Google is retiring the older version of Google Analytics July 1, 2023so it’s important to make the switch soon if you want to start building historical data in your new Google Analytics 4 property.
Fortunately, the process is very simple. Once you’ve made the switch, you’ll also be able to use the updated tools and features in Google Analytics (GA).
In this post, we take a closer look 🔎 at what’s new Functions of Google Analytics. Then we’ll show you how to switch to google analytics 4 in wordpress. Let’s begin!
Overview of Google Analytics 4
Google Analytics 4 is a new feature designed to provide more accurate reporting for businesses while protecting user privacy. Although Google Analytics 4 has been available for some time, it will soon completely replace Universal Analytics (UA).
Google recently announced that UA will stop collecting data in 2023. Therefore, now is the right time to switch to Google Analytics 4 and get acquainted with this new interface:

Google Analytics collects both website and application data. It also organizes reports around the customer lifecycle. For example, you can see which sources drive traffic to your pages, what actions users take, and whether they stay on your site after making a purchase or interacting with your content:

As you may already know, the world of digital marketing is moving towards a future without cookies. Due to the growing demand for online privacy, search engines like Google are issuing third-party cookies and placing more emphasis on first-party data.
Google Analytics 4 offers granular data controls to help website owners comply with GDPR regulations. For example the new one consent mode allows you to customize the behavior of your Google tags based on a user’s privacy settings.
It’s also worth noting that GA4 uses events instead of session-based data. Each of them has a unique name that describes a user action:

These events can include page views, transactions, downloads, and more. You can then click on an event to access more information about it. For example when you leave side viewyou can analyze user engagement on individual pages, view the number of events by country and much more.
Additionally, GA4 offers AI-powered insights that can help you plan your marketing campaigns more effectively. Analytics intelligence can predict trends and results for your website, including conversions and sales. You can use these insights to optimize your marketing strategy and reach the right audience.
How to switch to Google Analytics 4 on your WordPress website (in 3 steps)
Now let’s see how to switch to Google Analytics 4 in WordPress 🔀.
Step 1: Create a new Google Analytics 4 property
The first step is to create a new Google Analytics 4 property if you haven’t already done so.
⚠️ Note – If you’ve set up your Google Analytics property within the last year or so, you may have already created a GA4 property alongside your Universal Analytics property, as Google has pushed this approach heavily in the UI. In this case you can proceed to the next step.
First, log in to your Google Analytics Account and click ADMIN bottom left of your screen.
in the Account Be sure to select the correct GA account. Then in Property In the section, select your current Universal Analytics property. After that click on the GA4 setup wizard Possibility:

in the I want to create a new Google Analytics 4 property box, click Getting started. This opens a pop-up window.
If you have added Universal Analytics to your website using Global site tag code (gtag.js).see an option too Enable data collection using existing tags. If you select this, GA will use the existing tracking code on your website to collect data, so you don’t have to add it again.
However, don’t worry if you don’t already have the GA tracking code on your website. We’ll show you how to add it in the next step.
Either way, the next thing you need to do is select create property. Once the process is complete, you will see the following message:

You can click now Go to your GA4 property button to access the Setup Assistant:

Here are some settings for your new property. If you already have the GA tracking code on your website, you don’t need to do anything else – you’re done. If not, you can proceed to the next step.
Step 2: Get your GA4 tracking code
Next, you need to access your GA4 tracking code. In your Setup Assistantnavigate to collection section and click tag installation:

Among data streamsyou should see your new GA4 property:

If you click on it, you will get a window with some details about your stream:

Now scroll down to marking instructions and select that Global site tag (gtag.js) Possibility. You will then see your Google Analytics tracking code:

Go ahead and copy the code. The next step is to add it to your website.
Step 3: Add the tracking code to your website
Finally, you need to connect your WordPress site to your new Google Analytics 4 property. There are two main ways to do this, both made easy thanks to plugins. You can either add your GA tracking code in your header or footer, or add your measurement ID using a special Google Analytics plugin. Let’s take a closer look at each method.
Method 1: Paste the tracking code into your header or footer
You can start using GA4 on your website by adding the tracking code to your header or footer.
While you can do this manually with a child theme, an easier solution is to use a plugin like Head, Footer, and Post Injections.
This is a handy tool because it allows you to add code to your footer and header without having to touch your child theme files. That way, if you switch to a different theme in the future, those settings won’t be lost.
To get started, you need to go to your WordPress dashboard and install and activate the plugin on your website. Then go settings > header and footer and navigate to header and footer Tab:

Now you can paste your GA tracking code (from the previous step) into the PAGE SECTION INJECTION Area. You need to put this in the for field ON EACH SIDE.
Keep in mind, Google recommends that you add the GA tracking code to the header of your website. This allows it to track your traffic and user behavior more accurately, since header scripts tend to load before the rest of your page.
But you can also paste the code in your footer. Simply scroll down to do so BEFORE THE FINAL DAY (FOOTER) and paste your code in the appropriate field. Note that this method may not give you accurate insights into your visitors’ actions.
Method 2: Use the free GA Google Analytics plugin
You can also enable GA4 on your website using the free GA Google Analytics plugin.
Once you have installed the WordPress.org free plugin, navigate to settings > Google Analytics in your WordPress dashboard and click Plugin Settings:

in the GA Tracking ID you need to enter the measurement ID for your new Google Analytics 4 property. You can find these on the Web Stream Details page shown in step 2 above.
For tracking methodSelect Global site tag. Then click save Changes, and you’re done. Note that it may take up to 48 hours for data to appear in your Google Analytics account.
Add Google Analytics 4 to WordPress today
Google Analytics 4 includes several useful features for marketers and website owners. It allows you to track the consumer lifecycle, gives you details and information about important events, and helps you comply with online privacy laws.
More importantly, Google will stop processing new data for Universal Analytics July 1, 2023so you need to make the switch regardless of how you feel about the new features.
In this post we took a look how to migrate to google analytics 4 in wordpress. Here are the three steps you can follow:
- Create a new Google Analytics 4 property in your GA account.
- Get your GA4 tracking code.
- Add tracking code or measurement ID to your website by using Head, Footer and Post injections or Google Analytics GA plugin.
If you’re new to Google Analytics, you can also check out our Google Analytics Interface Guide to learn 👨🎓 how it works. We also have more advanced 🚀 posts on how to segment your analytics or set up custom SEO dashboards to track your efforts.