How to Track Engaged Time in Google Analytics

Find out how much time users spend actively doing stuff on your site


Lately there’s been a surge of interest in time-based metrics focused on the amount of time users spend actively engaged during a session. Because standard analytics solutions like Omniture and Google Analytics don’t provide this data out of the box, to track these metrics you generally need a specialized analytics tool, something like Chartbeat for example.

But it’s actually possible to get these metrics using Google Analytics. Here’s how.

First, get the Riveted plugin, which is just a small piece of JavaScript that you add to your site. It’s available as plain JavaScript or a WordPress plugin (the following instructions assume you’re using the plain JavaScript implementation).

More information about what the plugin does can be found on the Riveted project page but basically it listens for user activity signals like scrolling, clicking, using the keyboard, and page visibility to determine whether the user is an active or idle state.

Next, after your Google Analytics tracking code, load the script and call the riveted.init() function, like this:

https://gist.github.com/robflaherty/f71a837f8beca6242693

If you’re happy with the default settings, that’s it—you’re done!

Options

The default settings mean:

  1. Your bounce rate will not be affected.
  2. A user will be considered idle after 30 seconds of inactivity.
  3. An event will be sent to Google Analytics every 5 seconds updating the amount of active engaged time.

These settings are easy to adjust. For information on using these options, see the plugin options details on the Riveted project page.

Note: if you’re concerned about sending too many GA events, it may be wise to change the Report Interval to 10 seconds.

Advanced Stuff

The plugin provides a few methods for programmatically starting and stopping the timer. An example use case would be if you wanted to keep the Riveted timer going (i.e., continue to consider the user active) while a long video played.

You could do this with the riveted.trigger() function, and it might look something like this:

https://gist.github.com/robflaherty/02acf83028f8f432f48c

Looking at the Data

In Google Analytics you’ll find the data under Behavior > Site Content > Top Events > Riveted > Time Spent.

The total Event Value is the total engaged time, in seconds. In the screenshot above, this is 55,075 seconds = 918 minutes = 15 hours.

The reason that each 5-second increment gets its own label is that this allows you to create GA segments based on the amount of engaged time spent in a session.

For example, you could create a segment of all sessions with 60 seconds or more of engaged time and then cross-reference the segment with your site averages to see if certain traffic sources or user types lead to more active sessions.

On the reporting end of things it’s certainly not as slick or as user-friendly as something like Chartbeat. But it’s a quick and easy way to start measuring active user time, with an analytics tool you’re most likely already using.

Edit 8/24/15: Demo Dashboard

The Google Analytics API gives you a little more power and flexibility than the web interface. As a demo I put together a simple dashboard showing some of the data points that can be extracted from the Riveted events.

If you’re already running Riveted on your site you can use this tool to see a dashboard view of your site’s engaged time.