Are you looking to switch to the latest Google Analytics version?
Google is recommending website owners move to the new Google Analytics 4 because it sunset the previous Universal Analytics on July 1, 2023.
In this article, we will show you how to easily switch to Google Analytics 4 in WordPress.
Why Switch to Google Analytics 4?
Google Analytics 4 (GA4) is the latest version of Google Analytics. It lets you track your mobile apps and websites in the same account and offers new metrics, reports, and tracking features.
If you haven’t created a GA4 property yet, then now is the best time to switch to the latest version. That’s because Google closed down the old Universal Analytics on July 1, 2023.
What this means is that Universal Analytics will no longer receive and process data from your WordPress website. You can access your past data for now, but it will eventually stop showing old reports at some point. That means that all your old analytics data will be lost.
Switching to Google Analytics 4 will protect you from starting from scratch with no historical data. This way, you can future-proof your data while giving yourself plenty of time to learn the new Google Analytics dashboard and features.
That being said, let’s see how you can switch to Google Analytics 4 in WordPress.
Creating a Google Analytics 4 Property
If you already have an existing Google Analytics account using the old version, then you can easily create a new GA4 property and start sending stats to GA4.
First, you will need to visit the Google Analytics website and log in to your account.
After that, head over to the ‘Admin’ settings in the bottom left corner.
If you are on classic Google Analytics, then you will see the option to set up GA4.
Go ahead and click on ‘GA4 Setup Assistant’ under the Property column.
In the next step, the setup assistant will give you 2 options. You can create a new Google Analytics 4 property or connect an existing one.
Since we are setting up a new property, simply click the ‘Get Started’ button under the ‘I want to create a new Google Analytics 4 property’ option.
A popup will now appear with the details about the setup wizard.
If you’ve implemented your Universal Analytics using the Global Site Tag (gtag.js) code, then you’ll see an option to Enable data collection using existing tags.
This uses the existing tracking code on your site to collect information. That said, if you don’t already have the right tracking code on your website, then we will show you how to add it to your WordPress blog below.
For now, you can go ahead and click the ‘Create property’ button.
The setup wizard will add a new GA4 property and copy the Universal Analytics property name, website URL, timezone, and currency settings.
You can now view your new Google Analytics 4 property in the GA4 Setup Assistant.
Next, you’ll need to click on the ‘Go to your GA4 property’ button to see your Google Analytics tracking code.
From here, you can click on the ‘Collect website and app data’ option and select the ‘Manage data streams’ option.
You should now see your new GA4 property under Data Streams.
Go ahead and click on your new property.
A new window will slide in from the right, and you’ll be able to see your web stream details.
Note: Google Analytics 4 uses both ‘data stream’ and ‘web stream’. These both simply mean the flow of analytics data that Google Analytics receives from your website.
Simply click the ‘View tag instructions’ button at the top.
Next, you’ll see different ways to connect your WordPress site with Google Analytics.
For instance, Google Analytics can connect with a website builder or a WordPress plugin.
You can also manually add the tracking code to your site.
Simply switch to the ‘Install manually’ tab to view the code.
One thing you need to know is that Google Analytics 4 reports are quite different than what you are used to in Universal Analytics.
They have introduced new terminology, and many familiar metrics and reports are missing completely. Basically, if you were using common reports like the Top Landing Pages report or others, then you will have to recreate those from scratch in Google Analytics 4.
That’s why we recommend using MonsterInsights Pro or even the free version of MonsterInsights.
It will help you see all the familiar analytics reports right in your WordPress dashboard and make it easier to find the data you need for decision-making.
Not to mention, with MonsterInsights, you get all the powerful tracking features such as outbound link tracking, author tracking, and more, which can be enabled without writing any code.
Let’s take a look at how to easily set up Google Analytics 4 on your WordPress site with MonsterInsights.
Adding Google Analytics Tracking Code to WordPress Site
The best way to add Google Analytics tracking code to your WordPress website is by using MonsterInsights. This is the plugin that we use on WPBeginner.
MonsterInsights is the best Analytics solution for WordPress, and it’s trusted by over 3 million websites because it lets you easily set up advanced tracking without any coding skills.
You can use the MonsterInsights Lite version to set up Google Analytics in no time. There are also premium MonsterInsights plans that offer more features like custom dashboard reports, email summaries, scroll tracking, eCommerce tracking, premium integrations, and more.
First, you’ll need to install and activate the MonsterInsights plugin. For more details, please see our guide on how to install a WordPress plugin.
Upon activation, you’ll be taken to the MonsterInsights welcome screen in your WordPress dashboard. Simply click the ‘Launch the Wizard’ button to add Google Analytics to your site.
After clicking the button, the setup wizard will ask you to choose a category that best describes your website.
You can choose from a business website, publisher (blog), or online store. Once you’ve selected a category, click the ‘Save and Continue’ button.
In the next step, you’ll need to connect MonsterInsights with your WordPress site.
Go ahead and click the ‘Connect MonsterInsights’ button.
Once you click the button, you’ll need to sign in to your Google Account.
Simply select your account and click the ‘Next’ button.
Next, MonsterInsights will require access to your Google Analytics Account.
MonsterInsights App needs these permissions, so it can help you set up analytics properly and show you all the relevant stats right inside your WordPress dashboard.
You can click the ‘Allow’ button to continue.
After that, you’ll be redirected back to the MonsterInsights setup wizard.
To complete the connection, select your Google Analytics 4 property from the dropdown menu and click the ‘Complete Connection’ button.
Next, MonsterInsights will connect Google Analytics with your WordPress website.
On the next screen, you’ll see some recommended settings like file download tracking and affiliate link tracking.
You can use the default settings in the setup wizard. However, if you are using an affiliate link plugin, then you’ll need to enter the path you use to cloak the affiliate links.
Next, you can scroll down and select who can see reports and add different WordPress user roles.
Once you are done, click the ‘Save and continue’ button.
After that, MonsterInsights will show different tracking features that you can enable for your website.
You can scroll down and click the ‘Skip for Now’ button.
Next, you’ll see a checklist showing that you’ve successfully connected Google Analytics to your website.
For example, it will show that you are successfully connected to Google Analytics, the tracking code is properly installed, and the data is being collected.
Next, you’ll need to scroll down and enter your license key.
For this tutorial, we will simply click the ‘Complete Setup without Upgrading’ option.
That’s it. You’ve added Google Analytics 4 property to your WordPress site.
You can learn more by following our guide on how to install Google Analytics in WordPress.
Creating a Measurement Protocol API Secret
If you want to MonsterInsights to track eCommerce purchases, form conversions, and more advanced tracking in Google Analytics, then you’ll need to create a Measurement Protocol API Secret.
First, you’ll need to go back to your Google Analytics account and then go to Admin settings. Next, click on the ‘Data Streams’ option under the Property column.
Then you’ll need to select the Google Analytics 4 property that we created earlier.
Go ahead and select your property under Data Streams.
After that, you can scroll down to the ‘Events’ section.
Simply click the ‘Measurement Protocol API secrets’ option.
A new window will now slide in with your Measurement Protocol API secrets.
You will have to click the ‘Create’ button.
After that, enter a nickname for your API secret so that it’s easily identifiable.
When you are done, click the ‘Create’ button.
You should now see your Measurement Protocol API secret.
Simply copy the API secret from the ‘Secret value’ field.
After that, you can head back to your WordPress website and navigate to Insights » Settings from your dashboard.
Now click on the ‘General’ tab at the top.
Next, you will have to scroll down to the ‘Google Authentication’ section.
Go ahead and enter the Secret value you just copied in the Measurement Protocol API Secret field.
You’ve successfully added Measurement Protocol API Secret in MonsterInsights and set up Google Analytics 4 on your WordPress website.
To see how your website is performing, simply go to Insights » Reports. Here you’ll find all the data you need to make the right decisions to grow your website.
We hope this article helped you learn how to switch to Google Analytics 4 in WordPress. You may also want to see our ultimate WordPress SEO guide to improve your ranking or our comparison of the best email marketing services for small businesses.
If you liked this article, then please subscribe to our YouTube Channel for WordPress video tutorials. You can also find us on Twitter and Facebook.
Jac says
Hello,
I have a WordPress site and I have connected Google Analytics 4 with MonsterInsights (free version). I am replacing one of my pages with another page by changing the slug to match the original page. Will GA4 recognize that slug and keep any visitor info from the previous version of the page, or will it reset as if it were a new page?
Thanks
WPBeginner Support says
If the URL is the same then Google will consider them the same page. The page with the changed URL would need a 301 redirect from the old URL to the new URL if you wanted Google to consider them the same.
Admin
Jac says
Thank you so much for your quick reply!
Heidi says
I think Google is not tracking using Universal Analytics anymore… is this correct? Then if we follow these instructions, we should ignore anything having to do with Universal Analytics, right?
WPBeginner Support says
With Universal Analytics closed, you would not need to set up anything for Universal Analytics
Admin