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
And one for the number of seconds in focus since the last event, which will feed through the event value
3. Add the firing rule for the event
4. Add the tag that reports the timer event to Google Analytics
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!
Curious, the HTML script when do you fire that code? Should that not be fired on each page?
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.
Curious, the HTML script when do you fire that code? Should that not be fired on each page?
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.