Nomensa.com

You need to turn on Javascript in your browser to use this site!

Advanced Page View Tracking in GA4: Setup Guide | Nomensa

How to set up advanced page view tracking in Google Analytics 4 (GA4)

Posted on

4 minutes, 34 seconds
How to set up advanced page view tracking in Google Analytics 4 (GA4)

Setting up the tracking of Google Analytics pageviews for typical websites is relatively straightforward – include the tracking code in your website header tag, and hey presto! Every time a user clicks through pages on your website, the data is transferred to your Google Analytics Dashboard.

However, the rise of Single Web Page Applications (SWAs) in response to the ever-increasing demand for faster websites has caused pageview tracking to become more complex. SWAs work by dynamically rewriting the content into the page from the web server rather than loading an entirely new page, allowing for faster page transitions and for the website to feel more like a native app.

When tracking Single Web Applications in Google Analytics 4 through the classic method of a pageview tag that fires on all pageviews, this only records the session start pageview and not the subsequent pageviews made by a user. Traditional tag set-ups rely on dataLayer events for new page loads to fire the tag. The work-around for Universal Analytics is to use Google Tag Manager to set up a history change listener trigger or a custom event listener to track the dataLayer events and send pageview data to Analytics.

If you’re looking for help with Google Analytics 4 to improve your decision-making, we’d love to help. Our Analytics team offer a range of GA4 services to support your business needs.

How is pageview tracking different in Google Analytics 4?

We recently created a new Universal Analytics (UA) and Google Analytics 4 (GA4) property for a client who used dynamically loaded pages in their website and noticed some discrepancies in the total number of pageviews across both properties when using our current method of sending a pageview event with a custom event listener. The GA4 property had significantly lower pageviews than the UA property. We realised that Google Analytics 4 was not tracking pageviews correctly.

On investigation we learned that in Google Analytics 4 has enhanced measurement built in for pageviews, which automatically tracks each time a page loads or a browser history state is changed. This has been added as a new feature to Analytics to support tracking for Single Web Page Applications. To understand what was causing the problem we ran tests to understand how GA4 tracks pageview events, the effect of enhanced measurement and how this differs to Universal Analytics pageview session/hit data.

Tests A, B and C - description in text.

How did we conduct our tests?

We created three test tags and sent the user data to three new test properties in Google Analytics 4; we ran the tests for a week to ensure we had enough data to analyse. The tests were:

  • Test A: A standard GA4 configuration tag and Enhanced Measurement turned on in the Analytics property.
  • Test B: A GA4 configuration tag to fire on initialisation, then a separate pageview tag to fire on all pages, and Enhanced Measurement turned off.
  • Test C: A GA4 configuration tag to fire on initialisation, a separate pageview tag which fires using a history change listener, and Enhanced Measurement turned off.

After the week was up, we reviewed the results of our test. Below is a look at the top-level results. We could see that Tests B & C were significantly higher than the control Universal Analytics account. Test A, however, came within 4% of the total pageviews.

Graph showing test results. UA - 127,134 pageviews, GA4 (original) - 86,111, GA4 (Test A) - 132,458, GA4 (Test B) - 260,414, GA4 (Test C) - 172,976

Understanding the results

To better understand the results, we downloaded all the pageview data from all five analytics accounts and compiled them into an excel spreadsheet.

By colour coding the URLs, we sampled specific pages to understand the difference in pageviews numbers. We also noticed that some test tags had recorded no pageviews for some URLs enabling us to deduce why there was a discrepancy in the numbers.

  • Test B was double-counting pageviews roughly twice as much as Test A.
  • Test C also had extra pageviews from the tags, firing twice on new page loads and only once on SWA pages.

After verifying the double-counting in Test B and C using the debug mode in GA4, we also detected pageview numbers on specific URLs varied significantly despite the tags firing consistently in Google Tag Manager preview and debug mode. The closest pageview data to our Universal Analytics data was Test A.

So we extrapolated that GA4 interprets the data before displaying it in the Google Analytics Dashboard, which is the effect of Enhanced Measurement on the Google Analytics 4 Dashboard.

So what is our recommendation for tracking Single Web Page Applications?

We recommend using the standard Google Analytics 4 configuration tag in Google Tag Manager to send a pageview event and activating the Enhanced Measurement in the GA4 dashboard. We would also recommend running your GA4 property for as much time as possible before using the data in reports, allowing the machine learning element of Enhanced Measurement to create a more accurate set of data in your Analytics Dashboard.

“Why?” you might ask. Well, because we cannot completely turn off Enhanced Measurement in Google Analytics 4 – we have to trust that the standard configuration tag that Google has supplied is the most accurate way of tracking user engagement across your website. Our test proves that other methods of tracking pageviews can alter the algorithm for Enhanced Measurement and cause incomplete data for your website.

How can we help you?

GA4-graphic.png

With Google Universal Analytics becoming defunct it’s time to start thinking about moving to Google Analytics 4. Get in touch with our analytics team today via email, or phone, or fill out our contact form to find out how our team can support you.

Related posts

We'd love to hear from you

We drive commercial value for our clients by creating experiences that engage and delight the people they touch.

Email us:
hello@nomensa.com

Call us:
+44 (0) 117 929 7333

Nomensa.com

Please update your browser to view this site!