The Ultimate Guide to Adding Google Analytics 4 to WordPress

Published: 27 April 2023

Updated: 13 July 2023

Author Image
Victoria is a digital analyst @Viden, specializing in Google Analytics, Looker Studio and more, specializing in Google Analytics, Google Tag Manager (360), Looker Studio, etc. She has experience in delivering actionable data, helping brands understand their strengths and opportunities, and gain insight into their customers and target audience.
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:

  1. Understanding Google Analytics 4 and Its Benefits
  2. Setting up Google Analytics 4 in WordPress
  3. 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:

  1. Go to the Google Analytics homepage and log in with your Google account
  2. GA sign in

  3. 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
    • GA Create account

    • Or, select an existing account you want to set up your new property
    • GA create property

  4. 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.

  5. 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.
  6. GA property details

    You can name your property, report a time zone, and add other details here.

  7. Once finished, click “Next” to add a few more details; this includes business size and a couple of other questions
  8. GA create a property

  9. 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
  10. GA business details

  11. 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
  12. GA business objectives

  13. At this stage, you’ll be redirected to the “Data Streams” page; there, you’ll see different options, including iOS, Android, and Web
  14. GA data collection

  15. Choose “Web,” and a screen will appear, allowing you to set up your web stream
  16. GA data stream setup

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“:

GA4 measurement ID

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.

  1. In Google Tag Manager, click Tags > New
  2. GTM new tag

  3. Enter a name for the tag at the top (e.g., “GA4 Configuration”)
  4. In the Tag Configuration box, select Google Analytics: GA4 Configuration
  5. Google Analytics_ GA4 Configuration

  6. Next, configure your tag: in the field Measurement ID, enter your “G-” ID
  7. GTM measurement ID

  8. Add the “Pageview – All Pages” trigger and click “Save
  9. 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.

  1. On the main page of GTM Workspace, find your GTM ID code and click on it:
  2. GTM ID code

  3. Copy the GTM code from two sections and paste it into WordPress
  4. Log in to your WordPress admin dashboard
  5. On the menu on the left, click Tools, then select Theme file editor from the dropdown menu
  6. Paste the Google tag code snippet into the <head> tag editor and click Update file

WordPress theme file editor

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.

  1. In GA4 Property, find Data Streams under Admin > Property > Data Streams
  2. GA4 property data streams

  3. Follow the arrow under Data Stream
  4. GA4 data stream

  5. Find “View Tag instructions” at the bottom of the page
  6. GA4 view tag instructions

  7. Choose the most appropriate way for you to paste the gtag code to your site
    • Option 1. Choose “Install manually
    • Google Tag install manually

    • Option 2. “Install with a website builder or CMS
    • Google Tag installation instructions

    Check the link to see more information about the last option.

  8. Copy the gtag tracking code and navigate to your website to add the code
  9. Note: In this case, we use a WordPress website. There you can enter the code into the head of your website.

  10. Log in to your WordPress admin dashboard and add the code to the head of your site; click “Save” to save your code

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.

  1. Navigate to your website > “Plugins” and click the “Add New” button
  2. WordPress - add new plugin

  3. Find MonsterInsights, then click “Install Now
  4. WordPress install Monster Insights

  5. Once installed, you can click on the Activate Plugin button to activate it on your website
  6. WordPress activate MonsterInsights

  7. Once installed, you can click on the Activate Plugin button to activate it on your website
  8. 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:

    • Business website
    • Publisher (Blog)
    • eCommerce

    MonsterInsights setup page

  9. Choose a category that best describes your website, and click “Save and Continue
  10. Next, connect the plugin to your website by entering your license key and click on the “Connect MonsterInsights” button
  11. Connect MonsterInsights to your site

  12. Next, connect your Google Analytics with your MonsterInsights account
  13. MonsterInsights account

  14. Then, you’ll need to choose a profile to complete the connection
  15. MonsterInsights complete connection

    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.

  16. Choose your profile and then click the “Complete Connection” button
  17. Then go back to your Monsterinsights setup page and check recommended settings for the Google Analytics plugin
  18. MonsterInsights affiliate link tracking

  19. Configure these settings and click “Save and Continue
  20. Next, you’ll see options for more tracking options and other useful opportunities

MonsterInsights Enable website features

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.

Connect GA4 to your WordPress site

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

    1 September 2023

    How Marketing Teams Can Take Advantage of Generative AI

    Generative AI is a game-changer for marketing. Discover how you can use this technology to create more personalized customer experiences and drive more conversions.

    Learn more

    31 July 2023

    10 Tips for Marketing Male Supplements with Social Media

    Discover the best way to promote your male supplement company with our comprehensive guide. Learn how to use social media to promote your products and generate leads.

    Learn more

    20 July 2023

    How Marketers Can Use GA4 to Improve Campaign Performance

    Study our guide to GA4 for marketers and learn how to track your marketing performance, measure your ROI, and make better decisions.

    Learn more

    14 July 2023

    Understanding Data Filters in Google Analytics 4

    Want to get more out of your Google Analytics 4 data? Learn how to use GA4 filters to see the data that matters most to you.

    Learn more

    5 July 2023

    How to Set up Event Tracking in Google Analytics 4

    Learn how to set up event tracking in Google Analytics 4, track user behavior on your website or app, and use this data to improve your marketing campaigns and website performance.

    Learn more

    30 June 2023

    The Ultimate GA4 Handbook: Your Complete Guide to Understanding GA4

    Discover the ultimate guide to Google Analytics 4. Seamlessly transition from Universal Analytics to GA4 and unlock its full potential. Download the free handbook now!

    Learn more

    23 June 2023

    How to Use Google Analytics 4 to Grow Your Small Business

    Want to know how to use Google Analytics 4 to grow your small business? This article will show you how to set up GA4, track your key metrics, and use the data to make informed decisions.

    Learn more

    13 June 2023

    Understanding Enhanced Measurement in GA4

    Learn how to use Enhanced Measurement in Google Analytics 4 to collect more data about your users and improve your marketing and business decisions.

    Learn more