Skip to content →

Session Control – forcing a new session in Google Analytics

This is likely to be a niche post; there probably aren’t many sites where you’d need or want to use session control. Where I’ve used it has been on internal-facing, browser-based services that people will use to perform either the same task multiple times (for example entering customer details into a CRM system), or a range of different tasks within a fairly short timeframe (for example, entering, editing, or deleting customer records from a CRM system).

What’s the problem session control can solve?

If users are performing multiple tasks, without a break at least as long as the GA session timeout between them, it’s extremely hard to analyse the data you’ll get.

Let’s look at an enormously over-simplified example. Imagine a company has a browser-based CRM system that staff in call centres use. They want to make sure the system’s easy to use for staff, and as time is money, they want to see how long it takes people to complete various tasks.

The design of the site might be something like this:

page flow

If you implement code without using session control, and leave the default GA timeout at 30 minutes, you’ll end up with potentially the whole morning’s or afternoon’s interaction in one session (assuming the users take at least 30 minutes for lunch!). There’s no way to separate out the times when it worked from the times when it didn’t, or otherwise divide it into individual cycles through the process.

This means any goals you’ve got set up will be miles out, as users can only convert on each goal once in a session. So any funnels you set up to see where people dropped out will similarly be useless.

Say you wanted to see how many times users dropped out of the create a new record process; unless you use session control, you’ll have to resort to some extreme data manipulation using big query and R, but that’s one heck of a work-around.

A much better idea is to use session control. Essentially, this is a command added to a pageview or event that tells GA to either start a new session or end the current session.

What this will allow you to do is break a user’s activity up so that each task sits in a different session. This will let you do the kinds of analysis you’re used to on sites where people tend to complete a ‘task’ or purchase once in a session.

How to implement it:

It’s actually very simple to implement session control, as in the code is very simple. All it needs is either {sessionControl: “start”} or {sessionControl: “end”} adding to the end of an event or a pageview (or virtual page view), like this (obviously, you’re unlikely to want your event category as XXX, so add your own!):

ga(‘send’, ‘pageview’, ‘/pageview’, {‘sessionControl’: ‘start’});

ga(‘send’, ‘event’, ‘XXX’, ‘YYY’, ‘ZZZ’, {‘sessionControl’: ‘end’});

The real trick is working out which to put in and where. You basically need to work out the places where people will definitely start a new task. If you only put the session control at the end of a process, you’ll include partially completed processes in what should be the next session. This will give you weird results if there’s more than one task users can complete, as it’s likely to mix tasks in the same session (which is what we’re trying to avoid). It will also disguise drop-outs if they do the same task next, or there’s only one task they can do (as the uncompleted task will be included in a session during which they converted). So you need to take account of the ‘unhappy paths’ users can take when setting session control up.

In this example, it’s probably best to end the current session when users view the last page of the process, and start a new one on the ‘create new record’ page. If there’s no activity in a session it just gets ignored, so although this might look like it’ll create an empty session every time someone completes then starts the process again, in reality these won’t register. You could just start a new session on the home page, but ending it on the page view of the ‘record successfully created’ page means you’ll get a more accurate idea of the time taken to complete the process

(Visited 622 times, 1 visits today)

Published in Google Analytics Implementation/coding


Leave a Reply

Your email address will not be published. Required fields are marked *