Searching for the easiest way to set up Google Analytics 4 on WordPress? 😎
Google discontinued the older version of Google Analytics on July 1, 2023, so anyone wanting to use Google Analytics nowadays must register a new Google Analytics 4 property.
Fortunately, the process is very simple. You can also start using the updated tools and features in Google Analytics (GA).
In this post, we’ll take a closer look 🔎 at the new Google Analytics features. Then, we’ll show you how to switch to Google Analytics 4 in WordPress. Let’s get started!
An overview of Google Analytics 4
Google Analytics 4 is a new property that’s designed to provide more accurate reports for businesses while protecting user privacy. It was available for a while alongside the legacy Universal Analytics (UA) option and users were able to choose either one. However, in July of 2023, it went on to completely replace the latter.
Below is what the Google Analytics 4 interface looks like:
![The Google Analytics 4 interface](https://mllj2j8xvfl0.i.optimole.com/cb:jC7e.37109/w:1361/h:639/q:90/f:avif/https://themeisle.com/blog/wp-content/uploads/2022/06/ga-4-interface.png)
Google Analytics collects both website and application data. It also organizes reports around the customer life cycle. For instance, you can see which sources are driving traffic to your pages, the actions taken by users, and whether they remain on your site after making a purchase or engaging with your content:
![The Customer Life Cycle in GA4](https://mllj2j8xvfl0.i.optimole.com/cb:jC7e.37109/w:1363/h:579/q:eco/f:avif/https://themeisle.com/blog/wp-content/uploads/2022/06/reports-google-analytics-4.png)
As you may already know, the digital marketing world is moving towards a cookieless future. Due to the growing demand for online privacy, search engines like Google are phasing out 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 consent mode enables you to adjust the behavior of your Google tags based on a user’s privacy preferences.
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:
![events in action](https://mllj2j8xvfl0.i.optimole.com/cb:jC7e.37109/w:1697/h:698/q:eco/f:avif/https://themeisle.com/blog/wp-content/uploads/2022/07/events.png)
These events may include page views, transactions, downloads, and more. You can then click on an event to access more information about it. For example, if you go to page_view, you can analyze user engagement on individual pages, see the event count by country, and more.
Additionally, GA4 comes with AI-powered insights that can help you plan your marketing campaigns more effectively. Analytics Intelligence can predict trends and outcomes for your site, 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 look at how to switch 🔀 to Google Analytics 4 in WordPress.
- Step 1: Create a new Google Analytics 4 property
- Step 2: Get your GA4 tracking code
- Step 3: Add the tracking code to your website
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 done so already.
⚠️ Note – if you set up your Google Analytics property within the past year or so, you might have already created a GA4 property alongside your Universal Analytics property because Google was heavily pushing this approach in the interface. In that case, you can skip to the next step.
To get started, log into your Google Analytics account and click on ADMIN on the bottom left-hand side of your screen.
In the Account column, make sure to select the correct GA account. Then, in the Property section, select your current Universal Analytics property. After that, click on the GA4 Setup Assistant option:
![GA4 Setup Assistant option](https://mllj2j8xvfl0.i.optimole.com/cb:jC7e.37109/w:899/h:416/q:eco/f:avif/https://themeisle.com/blog/wp-content/uploads/2022/06/ga4-setup-assistant-option.png)
In the I want to create a new Google Analytics 4 property box, click on Get started. This will launch a popup window.
If you’ve added Universal Analytics to your site using the global site tag (gtag.js) code, you will see an option to Enable data collection using existing tags. If you select this, GA will use the existing tracking code on your site to collect data, so you won’t need to re-add it.
However, you don’t need to worry if you don’t have the GA tracking code on your site yet. We’ll show you how to add it in the next step.
Either way, next you’ll need to select Create Property. Once the process is complete, you will see the following message:
![The GA4 Property connection message](https://mllj2j8xvfl0.i.optimole.com/cb:jC7e.37109/w:1221/h:430/q:eco/f:avif/https://themeisle.com/blog/wp-content/uploads/2022/06/ga4-connected-message.png)
You can now click on the Go to your GA4 property button to access the Setup Assistant:
![The GA4 Setup Assistant](https://mllj2j8xvfl0.i.optimole.com/cb:jC7e.37109/w:1285/h:520/q:eco/f:avif/https://themeisle.com/blog/wp-content/uploads/2022/06/setup-assistant-ga4.png)
Here, you’ll find some settings for your new property. If you already have the GA tracking code on your site, you don’t need to do anything else – you’re finished. If not, you can move on to the next step.
Step 2: Get your GA4 tracking code
Next, you will need to access your tracking code for GA4. In your Setup Assistant, navigate to the Collection section and click on Tag installation:
![Tag installation option in GA4](https://mllj2j8xvfl0.i.optimole.com/cb:jC7e.37109/w:1271/h:417/q:eco/f:avif/https://themeisle.com/blog/wp-content/uploads/2022/06/tag-installation.png)
Under Data Streams, you should see your new GA4 property:
![Data Streams in GA4](https://mllj2j8xvfl0.i.optimole.com/cb:jC7e.37109/w:1273/h:424/q:eco/f:avif/https://themeisle.com/blog/wp-content/uploads/2022/06/data-streams.png)
If you click on it, you’ll get a window with some details about your stream:
![Web Stream Details](https://mllj2j8xvfl0.i.optimole.com/cb:jC7e.37109/w:1215/h:629/q:eco/f:avif/https://themeisle.com/blog/wp-content/uploads/2022/06/stream-details.png)
Now, scroll down to Tagging instructions and select the Global site tag (gtag.js) option. You’ll then see your Google Analytics tracking code:
![The GA4 tracking code](https://mllj2j8xvfl0.i.optimole.com/cb:jC7e.37109/w:902/h:593/q:eco/f:avif/https://themeisle.com/blog/wp-content/uploads/2022/06/tracking-code.png)
Go ahead and copy the code. The next step is to add it to your site.
Step 3: Add the tracking code to your website
Finally, you will need to connect your WordPress site with your new Google Analytics 4 property. There are two main ways to do this, both are made easy thanks to plugins. You can either add your GA tracking code in your header or footer or insert your measurement ID using a dedicated Google Analytics plugin. Let’s take a close look at each method.
Method 1: Insert the tracking code in your header or footer
You can start using GA4 on your site by adding the tracking code to your header or footer.
While you can do this manually using a child theme, a simpler solution is to use a plugin, such as Head, Footer and Post Injections.
This is a handy tool because it enables you to add code to your footer and header without having to touch your child theme’s files. This way, if you switch to a different theme in the future, you won’t lose these settings.
To get started, you’ll need to go to your WordPress dashboard and install and activate the plugin on your site. Then, go to Settings > Header and Footer and navigate to the Head and Footer tab:
![Inserting your tracking code into your header to get Google Analytics for in WordPress](https://mllj2j8xvfl0.i.optimole.com/cb:jC7e.37109/w:1157/h:602/q:eco/f:avif/https://themeisle.com/blog/wp-content/uploads/2022/06/head-and-footer-settings.png)
Now, you can paste your GA tracking code (from the previous step) into the <HEAD> PAGE SECTION INJECTION area. You’ll need to insert this in the field for ON EVERY PAGE.
Keep in mind, Google recommends that you add the GA tracking code to the header of your site. This enables it to track your traffic and user behavior more accurately, as header scripts tend to load before the rest of your page.
However, you can also add the code to your footer. To do this, simply scroll down to BEFORE THE </BODY> CLOSING TAG (FOOTER) and paste your code into the relevant field. Note that this method might 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 site by using the free GA Google Analytics plugin.
Once you’ve installed the free plugin from WordPress.org, navigate to Settings > Google Analytics in your WordPress dashboard and click on Plugin Settings:
![The GA Google Analytics settings](https://mllj2j8xvfl0.i.optimole.com/cb:jC7e.37109/w:1085/h:454/q:eco/f:avif/https://themeisle.com/blog/wp-content/uploads/2022/06/plugin-settings-ga.png)
In the GA Tracking ID field, you’ll need to enter the measurement ID for your new Google Analytics 4 property. You can find this on the Web stream details page shown above in step two.
For Tracking Method, select Global Site Tag. Then, click on Save Changes, and you’re done. Note that it may take up to 48 hours to start seeing data in your Google Analytics account.
Add Google Analytics 4 to WordPress today
Google Analytics 4 comes with several useful features for marketers and website owners. It enables you to track the consumer life cycle, gives you details and information on important events, and helps you adhere to online privacy laws.
More importantly, Google stopped processing new data for Universal Analytics (UA) on July 1, 2023, so regardless of how you feel about the new features, you can no longer opt for the legacy UA system.
In this post, we looked at how to make the transition 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 the tracking code or measurement ID to your website, using Head, Footer and Post Injections or the GA Google Analytics plugin.
If you’re still new to Google Analytics, you can also check out our guide to the Google Analytics interface 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.
Do you have any questions about switching to Google Analytics 4 in WordPress? Let us know in the comments section below!
Or start the conversation in our Facebook group for WordPress professionals. Find answers, share tips, and get help from other WordPress experts. Join now (it’s free)!