Google Analytics 4 (GA4) is the latest version of Google’s web analytics platform, designed to provide more comprehensive insights into user behavior across different platforms and devices. It’s the successor to Universal Analytics.
GA4 aims to offer a more modern and user-centric approach to analytics, focusing on event-based tracking, which allows for a more flexible and customizable approach to data collection.
Pageview Tracking
Automatic Pageviews
One of the more significant updates included with GA4 is pageviews (page_view) are now automatically dispatched when the browser URL (history) is updated.
When a user loads a page of your website or their browser history state is changed by the active site, a page_view is sent from your website to Google Analytics. Since the event is sent automatically, you no longer need to manually send pageview data to Analytics.
Previously, sending a page_view was a manual task where a developer or plugin was required to dispatch the event after each URL update.
This GA4 change affects Ajax Load More users as we have removed the manual pageview events from all add-ons that previously dispatched pageviews following Ajax requests with URL updates. The Filters, Next Page, SEO, Single Posts, WooCommerce, and Elementor add-ons are all using the new automatic pageview functionality provided by GA4.
Manual Pageviews
There are plenty of use cases for manually controlling pageviews. If you wish to disable automatic pageview functionality in GA4 you first need to update your gtag configuration to pass the send_page_view flag.
gtag('config', 'TAG_ID', {
send_page_view: false
});
JavaScriptTo manually dispatch a pageview, you would send a page_view event that includes a page title and URL.
gtag('event', 'page_view', {
page_title: '<Page Title>',
page_location: '<Page Location>'
});
JavaScriptNote: The almUrlUpdate callback function can be used for dispatching a manual pageview.
Wrapping Things Up
GA4 aims to offer a more modern and user-centric approach to analytics, adapting to the evolving digital landscape and user behavior. The automatic pageview update in GA4 is a game changer as it really takes the onus off the developer and puts it back in the hands of the site administrator to determine how and when to track pageviews.
What do you think of the new Google Analytics 4, let us know in the comments.