The Ultimate Guide to Adding Google Analytics 4 to WordPress

Published: 27 April 2023

Updated: 29 January 2024

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
  4. GA create property

    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

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

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

    1. 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
    2. Google Tag installation instructions

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

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

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

  • 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
  • Connect MonsterInsights to your site

  • Next, connect your Google Analytics with your MonsterInsights account
  • MonsterInsights account

  • Then, you’ll need to choose a profile to complete the connection
  • 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.

  • 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
  • MonsterInsights affiliate link tracking

  • Configure these settings and click “Save and Continue
  • 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

      28 March 2024

      Navigating the Data Deluge: Prioritizing Key Metrics in the Age of Google Analytics 4

      With the advent of Google Analytics 4 (GA4), the key business challenge becomes not collecting data but discerning what truly matters in the sea of data. 64% of marketing executives believe data-driven marketing is crucial to success in a hyper-competitive global economy. By prioritizing key metrics and avoiding the trap of tracking everything, businesses can […]

      Learn more

      3 January 2024

      How to Create a Viable First-Party Data Strategy in 2024?

      Discover the 9 key steps to build a first-party data strategy that maximizes customer data and enhances your marketing efforts.

      Learn more

      27 December 2023

      How To Create a Seamless Customer Experience to Win More Returning Clients

      Want customers hitting a repeat button? Learn the secrets to building a seamless customer experience that keeps them coming back for more.

      Learn more

      30 November 2023

      Maximize Your Data Retention in Google Analytics 4 (GA4) 

      Learn how to manage data storage and protect privacy with GA4 data retention settings.

      Learn more

      24 November 2023

      How to Read and Interpret Google Analytics 4 Reports to Drive Business Success

      Get to know how to read Google Analytics 4 reports to uncover customer insights, optimize marketing strategies, and drive business growth.

      Learn more

      11 November 2023

      How to Preserve Google Analytics’ Historical Data?

      Fearing to lose your Google Analytics’ historical data? Don't worry! This guide will show you four ways to save data during the UA-to-GA4 migration.

      Learn more

      9 November 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

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