How to track time on page with Google Tag Manager

google tag manager

Our script for accurate tracking of time on page beats Google’s default measurement to give you an accurate picture of how long users are spending on your page open and in focus.

This post translates the approach into Google Tag Manager. The setup consists of two tags (one custom), one firing rule and two variables.

Step by step:

1. Add the timer script as a custom HTML tag

2. Add two variables to access the data layer variables

One for the formatted time, which will feed through the event label

timeinfocus

And one for the number of seconds in focus since the last event, which will feed through the event value

intervalseconds

3. Add the firing rule for the event

littledata-timer

4. Add the tag that reports the timer event to Google Analytics

time-tag

Options and further information

You can change the timer interval in the custom HTML tag – the reporting will adjust accordingly. Choosing the interval is a trade-off between the resolution of the reporting and the load on the client in sending events, as well as Google’s 500 hit per session quota.

We’ve chosen ten seconds because we think the users who are in ‘wrong place’ and don’t engage at all will leave in under ten seconds, anything more is some measure of success.

If you’d like assistance implementing this or something else to get an accurate picture of how users interact with your site, get in touch!

 

Get Social! Follow us on LinkedIn, Twitter, and Facebook and keep up-to-date with our Google Analytics insights.
Comments 4
    1. GTM injects the HTML onto the page according to the firing rules. Yes, i’d run it on every page – but you could set to only run for landing pages.

    1. GTM injects the HTML onto the page according to the firing rules. Yes, i’d run it on every page – but you could set to only run for landing pages.

Comments are closed.

Prev
Accurate tracking of time on site
Ecommerce benchmarks for Shopify stores

Accurate tracking of time on site

There’s a flaw in the way Google Analytics measures ‘time on site’: the counter

Next
What are Enhanced Ecommerce reports?
Enhanced ecommerce reports

What are Enhanced Ecommerce reports?

In May 2014 Google Analytics introduced a new feature: Enhanced Ecommerce

You May Also Like