The Ultimate Guide to Adding Google Analytics 4 to WordPress
Adding Google Analytics 4 (GA4) to WordPress is a great way to get more detailed insights into your website’s traffic and performance. With GA4, you can better understand where your visitors are coming from, what they’re doing on your site, and how their actions impact conversion rates. This data can be invaluable for making informed decisions about where to invest your marketing budget and how to optimize your website for better results.
Fortunately, setting up GA4 on WordPress is relatively straightforward. You only need the tracking code from Google Analytics, an active WordPress account, and a few minutes of your time.
Table of Contents:
- Understanding Google Analytics 4 and Its Benefits
- Setting up Google Analytics 4 in WordPress
- Conclusion
Understanding Google Analytics 4 and Its Benefits
Google Analytics 4 is the latest version of Google Analytics, which differs from Universal Analytics in several ways. GA4 uses a different data model that provides more advanced features like cross-device tracking, better data privacy, and more actionable insights. One of the most significant benefits of using GA4 for WordPress users is the ability to track user behavior across multiple devices, providing a more accurate view of website performance. GA4 also uses machine learning to provide more meaningful insights into user behavior and helps you make data-driven decisions that can improve your website’s performance.
Our detailed article lets you learn more about Google Analytics 4 and its benefits.
Setting up Google Analytics 4 in WordPress
Creating GA4 Property
To start with GA4, you must create a new GA4 property and obtain a tracking code. You can create a new GA4 property from your Google Analytics account and follow the instructions to obtain your tracking code.
To do that, follow a few steps:
- Go to the Google Analytics homepage and log in with your Google account
- You’ll need to create a new GA4 property when you’re within your Analytics dashboard; at this point, you have two options:
- Select “Admin” and “Create Account”
- Or, select an existing account you want to set up your new property
- Now, you need to add all the property details. You’ll see the “Products Details” page by clicking on the “Create Property” button; here, you can add all the necessary property information.
- Once finished, click “Next” to add a few more details; this includes business size and a couple of other questions
- The next step is to choose “Business details“; select “Industry category” and “Business size” and then click the “Next” button at the bottom of the page
- Then on the step “Business Objectives,” choose the most appropriate objectives from the list and click on the “Create” button at the bottom of the page
- At this stage, you’ll be redirected to the “Data Streams” page; there, you’ll see different options, including iOS, Android, and Web
- Choose “Web,” and a screen will appear, allowing you to set up your web stream
We suppose you already have a Google Analytics account; we’ll click “Create property” on an existing account.
Note: Currently, we show the updated display of this process. Anyway, you can see the old ones. It’s OK.
You can name your property, report a time zone, and add other details here.
Add the relevant information, including your URL and stream name, and add or subtract any enhanced measurements you want; when you’re finished, choose the “Create Stream” button.
For the next steps, you should know GA4 Measurement ID; you can find it as it shown on the screenshot under “Web stream details“:
Note: To begin seeing the data, consider configuring the data collection in the new Google Analytics 4 property.
To start collecting the data, you should choose one of the following ways:
- Add your tag using Google Tag Manager
- Add the tag to a website builder or CMS-hosted website (e.g., HubSpot, Shopify, etc.)
- Add the Google tag directly to your web pages
We’ll currently consider the first option using Google Tag Manager (GTM). We believe you have a GTM account. If not, follow the instructions.
Creating a GA4 Configuration Tag in GTM
Start by creating a Google Analytics: GA4 Configuration tag to send data to your Analytics property.
- In Google Tag Manager, click Tags > New
- Enter a name for the tag at the top (e.g., “GA4 Configuration”)
- In the Tag Configuration box, select Google Analytics: GA4 Configuration
- Next, configure your tag: in the field Measurement ID, enter your “G-” ID
- Add the “Pageview – All Pages” trigger and click “Save“
After publishing the workspace in GTM, the data should start collecting in GA4 Property.
Using Google Tag Manager (GTM)
In the previous steps, we created GA4 Property and connected it with GTM. So, currently, it’s the easiest way to connect GTM with WordPress. First, you should find the GTM code and copy it.
- On the main page of GTM Workspace, find your GTM ID code and click on it:
- Copy the GTM code from two sections and paste it into WordPress
- Log in to your WordPress admin dashboard
- On the menu on the left, click Tools, then select Theme file editor from the dropdown menu
- Paste the Google tag code snippet into the <head> tag editor and click Update file
Note: If you change your WordPress theme, you must repeat this process as the header.php might be overwritten.
That’s it! However, there’re two other options to add GA4 to WordPress with the help of a plugin. Let’s quickly look at them.
Using a GA Tracking Code
First, you should find your Global Site Tag (gtag.js), install it on your WordPress website, and get data and analytics from Google Analytics 4.
- In GA4 Property, find Data Streams under Admin > Property > Data Streams
- Follow the arrow under Data Stream
- Find “View Tag instructions” at the bottom of the page
- Choose the most appropriate way for you to paste the gtag code to your site
- Option 1. Choose “Install manually“
- Option 2. “Install with a website builder or CMS“
- Copy the gtag tracking code and navigate to your website to add the code
- Log in to your WordPress admin dashboard and add the code to the head of your site; click “Save” to save your code
- Navigate to your website > “Plugins” and click the “Add New” button
- Find MonsterInsights, then click “Install Now”
- Once installed, you can click on the Activate Plugin button to activate it on your website
- Once installed, you can click on the Activate Plugin button to activate it on your website
- Business website
- Publisher (Blog)
- eCommerce
- Choose a category that best describes your website, and click “Save and Continue”
- Next, connect the plugin to your website by entering your license key and click on the “Connect MonsterInsights” button
- Next, connect your Google Analytics with your MonsterInsights account
- Then, you’ll need to choose a profile to complete the connection
- Choose your profile and then click the “Complete Connection” button
- Then go back to your Monsterinsights setup page and check recommended settings for the Google Analytics plugin
- Configure these settings and click “Save and Continue”
- Next, you’ll see options for more tracking options and other useful opportunities
Check the link to see more information about the last option.
Note: In this case, we use a WordPress website. There you can enter the code into the head of your website.
How to Preserve Google Analytics’ Historical Data?
Installing a Plugin
There’re many Google Analytics plugins, including MonsterInsights, ExactMetrics, and Analytify. Let’s take MonsterInsights as an example. First, let’s install and activate the MonsterInsights plugin.
When the plugin is activated, you’ll see the plugin setup wizard open to guide you through the setup. There you’ll have to choose from three options:
Note: If you have multiple websites connected to your Google Analytics account, choose the right website property there. If you only have a GA4 property, choose it.
Congratulations! You’ve successfully added Google Analytics 4 to WordPress.
Conclusion
By adding Google Analytics 4 to your WordPress site, you can unlock valuable insights into your website’s performance, user behavior, and engagement. With the help of this guide, you can effortlessly add GA4 to WordPress and take full advantage of its advanced features. We recommend using integration within GTM to simplify further data collection. However, if you struggle to set up or utilize GA4 to its full potential, our team of analytics experts is here to help. Turn to our analytics services for personalized assistance and guidance in interpreting and utilizing GA4 data to optimize your website and achieve your business goals. Don’t let valuable insights slip away – reach out to our team today to get started.
Get in touch
Got a question? We'd love to hear from you. Send us a message and we'll respond as soon as possible.
By clicking submit, you agree to our Privacy Policy
Latest Insights
Get the tips from our experts to optimize and scale your campaigns