How to Track WordPress Blog Traffic in Google Analytics 4

Since Google’s announcement of Universal Analytics’ departure in July, 2023, many marketers have begun the great migration to Google Analytics 4. And so far it has been great!

But there are still a few hang ups.

Much of the way Universal Analytics was built – from Goals to page tracking, and more – has been re-designed, and this has left many scratching their heads when searching for the right reports. And many have asked specifically:

“How can we track WordPress blog post traffic in Google Analytics 4?”

Blog post traffic reports in GA4

Tracking blog traffic in GA4 doesn’t seem to be simple (we could be missing something, but we don’t think so).

Some URL structures make it difficult to track blog traffic, especially ones without the /blog/ prefix. For example:


So what can you do?

The answer (as we’ve found it) lies in Google Tag Manager and Google Data Studio reports. In this post, we’ll focus specifically on tracking blog post traffic that’s missing the /blog/ URL prefix.

Note: If your blog posts do have a /blog/ URL prefix, you’re in luck. Click here to see how you can create a Data Studio report to view this traffic.

Installing Google Tag Manager

If you aren’t using Google Tag Manager for your Google Analytics 4 tracking code in WordPress, we highly recommend making the switch. It will be necessary for this tutorial.

We’ll be using the WordPress plugin GTM4WP to install Google Tag Manager in this walkthrough. This plugin allows us to automatically send dataLayer information about our pages to Google Tag Manager without needing to hard-code any information into our sites. More on this later.

To begin, head to WordPress and install GTM4WP, then activate the plugin:

gtm4wp plugin installation for wordpress gtm blog post traffic tracking

Next, head to the GTM4WP settings and input your Google Tag Manager code.


To complete this step, you’ll need to a) have a Google Tag Manager account created, b) configure your Google Analytics 4 account in Google Tag Manager, and c) head into your Google Tag Manager account and follow these steps:

  1. Click on “Admin” at the top left-hand corner of the page
  2. Copy the GTM code at the top right-hand corner of the page
installing google tag manager on wordpress with gtm code

Next, head to Settings > Google Tag Manager within your WordPress dashboard and paste your Measurement ID into the input field.

Note: After inputting the code and saving the changes, you may have to re-enable the container code in the GTM4WP settings.

Next, head to the “Basic Data” tab at the top of the page and ensure “Posttype of current post/archive” is checked.

enabling post type data layer information in wordpress for google tag manager

Now Google Analytics 4 should be installed and working through Google Tag Manager with dataLayer information being send to GTM about your Post Types. To ensure the proper data is being sent to Google Tag Manager, let’s do some tests.

Testing Google Tag Manager dataLayer

First, head to Google Tag Manager and click “Preview” in the top-right hand corner of the page.

Next, enter your website address on the page and click “Connect.” Then navigate to a blog post on your site that opens in a new tab.

After viewing a blog post, head back to the GTM Tag Assistant window and click on the “Window Loaded” API Call that’s connected with your blog post page view on the left side of the page. Then, click on the “Data Layer” tab. You should see dataLayer information showing here – specifically, the “pagePostType2” item equalling “single-post”:

google tag manager data layer page post type 2 settings for wordpress blog posts

If you’d like to have a team of experienced marketing engineers handle your UA -> GA4 migration, 3.7 Designs is now offering a complete Universal Analytics to Google Analytics 4 transfer service. Send us a message if you’d like to avoid the headache.

Awesome! We’re now ready to create Events within Google Tag Manager that we’ll later use as filters within Google Data Studio to return traffic on blog posts.

Creating a Google Analytics 4 Event for blog post views

Let’s create a GA4 event that fires every time someone views a blog post on your site. To accomplish this, we’re going to use the dataLayer information sent to GTM like we covered in the last section.

Creating a variable

To start, head to Google Tag Manager and click “Variables” in the left-hand menu. Then click the “New” button in the “User-Defined Variables” section:

creating custom pagePostType2 variables in google tag manager

Click within the Variable Configuration box and select “Data Layer Variable” in the right-hand menu.

custom data layer variable for pagePostType2 in google tag manager

For the “Data Layer Variable Name” input, paste in pagePostType2 – and leave the “Data Layer Version” as Version 2. You can also give the variable a name – we’ll call ours “dlv – pagePostType2:”

configuration for the pagePostType2 variable in google tag manager

Creating a trigger

Now we’ll create a trigger that fires each time a user visits a blog post.

To do this, we’ll create a trigger that looks through our dataLayer information when the “Window Loaded” API Call is sent on each page view, and we’ll check to see whether the variable we set – pagePostType2 – is equal to “single-post.” Let’s go!

To start, head to “Triggers” within Google Tag Manager and click “New.”

creating a window loaded trigger for pagePostType2 in google tag manager

Next, click into “Trigger Configuration” and select the “Window Loaded” trigger type:

selecting the window loaded trigger type in google tag manager

Select the “Some Window Loaded Events” option. Then, find the variable you created in the previous steps named “dlv – pagePostType2” in the first dropdown. In the second dropdown, select “equals.” In the third input field, write “single-post” like in the following image. You can name this trigger “Single Post View.”

creating a wordpress blog post view trigger in google tag manager

Great! Our variable is now created and we’re ready to create a Google Analytics 4 event.

Creating a blog post view event

Let’s head over to “Tags” in the left hand menu and click on “New.”

creating a tag in gtm

Next, click into “Tag Configuration” and select “Google Analytics: GA4 Event:”

Now we’ll fill out the Event details. Follow these steps:

  1. Name the tag whatever you like – we’ll go with “GA Event – Blog Post View”
  2. Select your GA4 configuration tag
  3. Name the event “post_view”
  4. Select the “Single Post View” trigger we created in the last step
  5. Click “Save”
creating a gtm tag to fire on every wordpress blog post view

Awesome! Now we’re ready to test our event.

Testing the GA4 blog post view event

To begin, let’s click the “Preview” button in Google Tag Manager.

In the window that appears, enter your website URL and click “Connect.” When your website opens in a new tab, navigate to one of your blog posts.

Then head back to the GTM Tag Assistant and click the “Window Loaded” API Call in the left-hand menu. You’ll know you succeeded in your setup if you see the “GA Event – Blog Post View” Event firing when you viewed the post!

If you’d like to have a team of experienced marketing engineers handle your UA -> GA4 migration, 3.7 Designs is now offering a complete Universal Analytics to Google Analytics 4 transfer service. Send us a message if you’d like to avoid the headache.

…but we aren’t done yet. What if we want to view the traffic to each of our blog posts individually?

That’s where Data Studio comes in.

Creating a Data Studio report for blog post views

To start, head to Data Studio and click “Blank Report.”

After creating the report, a section will appear asking you to “Add data to report.” We’re going to use data from our Google Analytics account, so we’ll select the “Google Analytics” option.

In the next step, find your Google Analytics account and click “Add.”

Now we’re ready to begin building our report.

Building the report

By default Data Studio creates a Table chart when you create a new report. This is perfect, as we’ll be using this table to create the report – but we’ll have to make some changes first.

If your table wasn’t created by default, just click the “Add a chart” button in the top menu and select the first item under “Table.”

To begin, select the chart. Then follow these steps (see image for instructions):

  1. Select the default Dimension (ours was Event name). Type in “Page path and screen class” and select the option.
  2. Click the default Metric under “Metric” (ours was “Views”). Search for “Total users” and select it.

Next, scroll down the options and select “Add a Filter.”

In the “Create filter” window, follow these steps:

Then click “Save.”

Congratulations! You’ve now added the filter that will allow you to see blog post traffic to each of your posts within Google Data Studio.

Note: If you’ve just added the “post_view” event, it’s likely your chart will show “no data.” You’ll have to wait until your event starts firing in Google Analytics 4 before you’ll see any data in this report.

Once your data populates (and after a few minor style tweaks), you can end up with a nice, simple report:

Reports for /blog/ URL prefixes

If your blog posts have a /blog/ URL prefix (ex., tracking traffic will be much easier for you.

You can follow the steps above to create a Data Studio report and configure it to show the right data. Once you begin applying the filter, instead of filtering by “Event name,” simply filter by “Full page URL -> Contains -> /blog/” like so:

…and you should be good to go!

Confused? We don’t blame you.

Making the switch from Universal Analytics to Google Analytics 4 is not an easy task (trust us: Google’s multi-hour support documentation walkthrough doesn’t help much.) Many business owners just don’t have the time to learn all of GA4’s new features and complexities.

Luckily, we can help.

If you’d like to have a team of experienced marketing engineers handle your UA -> GA4 migration, 3.7 Designs is now offering a complete Universal Analytics to Google Analytics 4 transfer service. Send us a message if you’d like to avoid the headache.