Adding Google Analytics 4 to WordPress: Step-by-Step Guide

Adding Google Analytics 4 to WordPress

Want to add Google Analytics 4 (GA4) to WordPress? You’re in the right place!

In this step-by-step guide, we’ll go over how to add the newest version of Google Analytics, GA4, to WordPress using the best plugin for the job: ExactMetrics.

ExactMetrics is the best plugin to use to add Google Analytics 4 to WordPress because it’s one of the only plugins that allows you to connect both your Universal Analytics and GA4 properties to your WordPress site at the same time.

Ready to get started? Let’s go!

ExactMetrics is the best WordPress Analytics plugin. Get it for free!

Add GA4 to WordPress in 4 Steps

  1. Create a Google Analytics 4 Property
  2. Install and Set Up ExactMetrics
  3. Set Up Dual Tracking
  4. Create an API Secret

Step 1: Create a Google Analytics 4 Property

If you don’t have a GA4 property set up yet, you’ll need to do that first. The instructions for this are different if you already have an Analytics account vs if you need to create one. Let’s take a look at the process for each.

Directions for if you already have a Universal Analytics property
Directions for if you do not have a Google Analytics property set up yet

If you already have a Universal Analytics property…

If you already have a Google Analytics account and a Universal Analytics property, you can go through the process of creating a GA4 property pretty easily by following Google’s Setup Assistant.

To access the assistant, head to the Admin cog then GA4 Setup Assistant in the middle column.

GA4 Setup Assistant

Next, click the blue Get Started button.

Get Started with the GA4 Setup Assistant

Then, click the Create Property button. The last option will either be checked or not based on which version of the tracking tag you currently have installed.

Create property

Your new property is created! Go ahead and click See Your GA4 Property.

See Your GA4 Property

Alright, let’s leave that tab open now and go to the next step.

If you do not have a Google Analytics property set up yet…

If you don’t have Google Analytics yet, follow these steps to set up your account and create both GA4 and Universal Analytics properties at the same time.

The first thing you’ll need to do is log in or sign up for a Google account.

To get started, you’ll need to open the Google Analytics website and click the Sign in to Analytics link or Start for free button in the top right corner of the page.

Google-Analytics-Sign-Up-Screen

Next, you can log in to your existing Google account if you have one, or click the Create account link to create a new Google account.

sign in to google

Now, click the blue Start Measuring button.

click the start measuring button

Next, you’ll need to enter the Account name for your Google Analytics account. You’ll also see different data sharing settings. Make sure you check all the boxes and then click Next.

enter-account-name-for-ga

Now, you’ll have to enter the property details of your website. Start by entering a name, selecting a reporting time zone, and choosing your currency.

Google Analytics Property Setup

Fill in your business details and click Create. You may see a popup at this point to accept the Google Analytics Terms of Service. Go ahead and check the checkbox and click I Accept.

Now, a popup window should now appear that contains Google Analytics Terms of Service Agreement.

Review the terms of service and then check the box below the terms about GDPR.

Google Analytics Terms of Service

On the next screen, you’ll be offered a guided tour. Go ahead and go through it if you want a guided tour of your account.

Google Analytics Property Tour

Then, it’s time to set up your data stream. If you’ve navigated away from the page, head back to Admin » Data Streams:

GA4 Data Streams Page

Next, click the Web button if you’re tracking a website:

Web data stream setup - GA4

On the next screen, fill in your site’s URL and name, then choose your Enhanced Measurement settings. Please note, if you’re going to use ExactMetrics (the best premium Google Analytics plugin for WordPress), turn Enhanced Measurement OFF. ExactMetrics tracks those events for you. Leaving tracking turned on in Google Analytics could disrupt your tracking through ExactMetrics. When it’s filled out, click Create Stream.

Set up GA4 data stream

Once you create your stream, you’ll land on the Web Stream Details page. Here you can toggle on and off enhanced measurement, access your tracking code, and find a lot of other options and settings. We’re going to leave this page open for now and move on to the next step.

Step 2: Install and Set Up ExactMetrics

Already have the plugin? Skip to step 3.

To start, head to the Pricing page and get started with ExactMetrics. Once you complete checkout, download the plugin.

Download Exact Metrics

Next, upload it to your website.

Upload Plugin Zip File

Now that you have ExactMetrics installed, you can add your license key and connect your Google Analytics account. To get set up, click on ExactMetrics under your WordPress Dashboard and click the big green “Launch the wizard!” button.

ExactMetrics Setup Wizard

Once you’re in the wizard, you’ll get to this page where you can add your license key and connect with Google Analytics:

Connect ExactMetrics

For more details on this step, check out our guide on How to Add Google Analytics to Your WordPress Site.

Step 3: Set Up Dual Tracking

Here’s how to add your GA4 property to the Dual Tracking box in ExactMetrics.

A GA4 property has a Measurement ID, which is in the format of G-XXXXXXXXXX.

To find your Measurement ID, go to Admin » Property » Data Streams and then click into the data stream:

You’ve located your Measurement ID and now you can add it to ExactMetrics.

First, log into your WordPress site and go to ExactMetrics » Settings.

Under the Google Authentication section, you’ll see a Dual Tracking Profile option.

Copy your Measurement ID and then paste it into the option.

Once you insert the ID, the settings will be saved.

That’s it! You’re now dual tracking both a GA4 and UA property on your WordPress site.

Step 4: Create an API Secret

In order to track eCommerce events and form submissions to your Google Analytics 4 property, you’ll need to create a Measurement Protocol API Secret and insert the generated secret value into your ExactMetrics settings.

Log into analytics.google.com and click into the Admin of your GA4 property.

Then, click into your existing data stream.

Within the Additional Settings section, click into Measurement Protocol API secrets.

Click the Create button to create a new API secret and give it a Nickname.

Copy the newly created Secret Value.

Log into your WordPress admin and go to ExactMetrics » Settings and paste the Secret Value into the Measurement Protocol API Secret field.

That’s it! You’ve successfully set up your Measurement Protocol API Secret in GA4.

Your WordPress website is now connected to both GA4 and Universal Analytics. Because you used ExactMetrics and connected both properties, you’ll have the best of both worlds with your tracking.

Now, are you wondering what to track? Read 8 Types of Google Analytics Reports to Track (The Best Ones).

Don’t forget to follow us on Twitter and Facebook to see all the latest Google Analytics tutorials.

Want to Try ExactMetrics for Free?

Enter the URL of Your WordPress website to install ExactMetrics Lite.

Add a Comment

We're glad you have chosen to leave a comment. Please keep in mind that all comments are moderated according to our privacy policy, and all links are nofollow. Do NOT use keywords in the name field. Let's have a personal and meaningful conversation.