02.01.2024
The ‘Site Speed,’ ‘Page Timings’ reports, and the ‘Avg. Page Load Time (s)’ metric, which are available in Universal Analytics, are not present in Google Analytics 4. Google adds new reports and metrics with updates every day, but currently, you cannot track the loading time of your pages in GA4. However, by using Google Tag Manager, we can create a report about the page loading time in GA4.
Step 1: Variables
We are creating a custom JavaScript variable. (Page Load Time)
This JavaScript variable will utilize the Performance Navigation Timing API. With this API, we will calculate the time between loadEventEnd and startTime (in milliseconds), providing us with the page load time. We then convert the obtained number from milliseconds to seconds.
Step 2: Triggers
In the next step, we will create a trigger that will activate our GA4 tag using the ‘Window Loaded’ trigger type. To our trigger, we add a condition to trigger only if the ‘Page Load Time’ variable has a value greater than zero.
Step 3: Tags
Now that we have created our custom JavaScript variable capturing page load time and our trigger, it’s time to create our GA4 event tag. With this tag, the page load time will be sent to Google Analytics 4.
Step 4: Custom Metric Parameter
After creating our ‘page_load_time’ event, we need to register our ‘loading_time_sec’ parameter as a custom metric in GA4.
You can add this in Google Analytics 4 by going to ‘Admin’ -> ‘Data View’, ‘Custom Definitions’ -> ‘Custom Metrics’ tab.
Step 5: Test and Publish
The final step is to test our GTM container. After loading a page from our website using Google Tag Assistant, select the ‘Window Loaded’ dataLayer event on the left.
Then select the ‘GA4 Event – Page Load Time’ tag.
Now the Google Tag Manager container can be published. Follow the steps below to track your page load time in GA4.
We will be able to prepare our reports from GA4 -> Explore section and Looker Studio. In our blog post, we will prepare our report via Looker Studio. Let’s create a table and add ‘Page Path’ as the dimension. I used ‘Page Path,’ but other page-based dimensions can be added as well. Add ‘Event Count’ and ‘Average Page Load Time’ as metrics.
Later, we need to add a filter because there might be cases where the Page Load Time tag is not triggered during a page view. For example, if the event is set not to trigger on every page, if there was an error, or if the page load time was measured as zero seconds (or less), etc. We want the report to filter only for cases where the ‘page_load_time’ event occurred.
This will provide a table showing the average loading times for the pages on your website.
Now, using Google Tag Manager, we can track and report page load time in Google Analytics 4 and Looker Studio.
Perfist Blog
Similar Articles
With the transition from Universal Analytics to Google Analytics 4, there may be some issues you need to resolve. One of these issues is “unassigned” traffic. Dimensions appearing as “unassigned” / (not set) in reports negatively impact your ability to analyze and optimize. We will discuss the causes of “unassigned” traffic in your GA4 reports […]
Read More
Beginner Level Web/App AnalyticsEarlier this year, Google Cloud announced that BigQuery data warehouse supports automatic data transfer from Facebook Ads. In its preview stage, this feature offers an alternative way to enhance analysis and insights by allowing the scheduling of data loading tasks. With this integration, the need for third-party tools or manual code execution is eliminated. This […]
Read More
Mid Level Web/App AnalyticsBy combining the app and web data in Google Analytics 4, app analysis has become more easily trackable. Firebase Analytics allows you to easily track your iOS or Android app with GA4. With numerous different tools available for mobile app tracking, being able to see both web and app data within the same property is […]
Read More
Mid Level Web/App AnalyticsBusinesses want to use as much data as possible from analytics and marketing cookies. However, in order to collect and use this data, they need to comply with laws such as KVKK/GDPR. By enabling Cookie Mode, Google helps to use cookies according to the level of consent. In other words, with Cookie Mode, users’ privacy […]
Read More
Mid Level Web/App Analytics