Track Page Load Time in Google Analytics 4 | BCS Track Page Load Time in Google Analytics 4 | BCSBCS

Track Page Load Time in Google Analytics 4

Google Analytics BCS 7 months ago (04-22) 862 Views 0 Comments

This article introduces how to track Page Load Time in Google Analytics 4, there are two ways:

  • One is to use a separate event to track the Page Load Time. For example, after the web page is loaded, send a separate event to track the Page Load Time.
  • One is to incorporate the Page Load Time into Page View: use custom JavaScript to obtain the Page Load Time through the browser API, set it as an event parameter, and send it along with the Page View. This method will not increase the number of requests sent.

This introduction is the second method. There are two things to pay attention to when using this method:

  • The trigger condition must be that the window is loaded, not Page View, because if you use Page View, the window may not be loaded yet, which will result in the Page Load Time not being obtained. If the window is loaded, it must be loaded and you can obtain it. 
  • Do not trigger the event before the window has been loaded. If the event is triggered faster than the PageView, it will affect attribution.

Next let’s see how to set it up:

Variables: Custom JavaScript

The purpose of this variable is to obtain the Page Load Time through the browser API

Track Page Load Time in Google Analytics 4

 

Source Code:

function(){
  var timing = performance.getEntriesByType('navigation')[0] || performance.timing;

var load_time = ((timing.loadEventStart-timing.fetchStart)/1000).toFixed(2);

if(load_time>0){
	return load_time;
 }
}

 

 

Tag: Default PageView Tracking

Find the Tag of GA4‘s default pageview tracking and add it in Shared event settings:

Track Page Load Time in Google Analytics 4

Change the Trigger to window loaded:

Track Page Load Time in Google Analytics 4

Preview

After setting, preview and debug in GTM:

Track Page Load Time in Google Analytics 4

As you can see, the event parameter page_load_time accurately tracks Page Load Time.

Custom Definitions

In GA4, click 「Admin」——「Custom Definitions」——「Custom metrics」——「Create custom metrics」, and then make the following settings:

Track Page Load Time in Google Analytics 4

That’s it.

Explore:Data Verification

After collecting some data, you can use Free form to verify it in Explorations:

Track Page Load Time in Google Analytics 4

 

The Page Load Time here is the sum of multiple web pages. If you want to see the average, you can use the calculation metrics. The formula is {Page Load Time}/{Events count}. The report is as follows:

Track Page Load Time in Google Analytics 4


If you don't understand, You can leave a comment below.
Like (6)
Post my comment
Cancel comment
Expression Bold Strikethrough Center Italic

Hi, you need to fill in your nickname and email!

  • Nickname (required)
  • Email (required)
  • Website