Features

Cohort analysis in Google Analytics

Cohort analysis in Google Analytics

Copyright © Matt Clarke

You can find out lots about your customer behaviour by doing a cohort analysis in Google Analytics, using a simple event tracking hack.

A while ago I read an interesting post from Dan Hill which explained how he's added functionality to his Google Analytics tracking to allow him to perform a simple cohort analysis. 

Dan's technique is designed for content sites, so it runs some queries on logged-in users to find out when they signed up and uses Ruby on Rails to add the data to two custom variables for the join month and join year using the visit level scope.

He then uses the advanced segments in the Google Analytics interface to create custom segments for each cohort, say "November 2011 signups", and then selects a cohort to see how it differs in its conversion rates for his goals. 

That's a neat way of achieving it, but with only five custom variables available in the free version of GA, their use needs careful monitoring and most of mine are already full. So I've come up with a similar solution which uses event tracking instead. 

 

Using event tracking for cohort analysis

While event tracking probably wasn't designed to do stuff like this, I find it lends itself well to this kind of hack.

Essentially, you can use GA's event tracking feature like a database with four fields (category, action, label and value) and it will neatly store your data, crunch your numbers and allow you to segment against it. 

You'd have your work cut out to produce a similar application so easily if you weren't using Google Analytics, particularly for the data charting. Plus, it's all in one place for analysis with the rest of your data, which makes it really powerful. 

However, event tracking isn't perfect and if you use it in this way you'll need to think ahead about how the data will be displayed in GA.

It used to be the case that setting events affected your bounce rate, but the new opt_noninteraction value now overcomes this. To me, the greatest annoyance is the fact that, for no apparent reason, the value field needs to be an integer (ie. 1) and not a float (ie. 1.4).

This means you'll need to use rounding to ensure any values passed are integers, which makes the event value and average value metrics approximate.

On the plus side, if your events are purchase related, you'll still get e-commerce data for each event, so you can still get at the data, just not quite so neatly. 

How it's done

I work on e-commerce sites, so I'm running my event tracking code only when a purchase is made. I trigger the code to run only on the payment confirmation page and run a quick SQL query using PHP to get the date of the user's first order. 

I then apply that date to a PHP function which re-formats the date to provide three different values: the cohort year (ie. 2011), the cohort month (ie. 09) and the cohort quarter (ie. Q3). 

I then send these values to my Google Analytics tracking code and assign them to three different _trackEvent calls, one for "Monthly cohorts", one for "Annual cohorts" and one for "Quarterly cohorts".

It's vital that when using this technique that you don't try to send more than 10 events at once - since Google Analytics has an undocumented feature in place to prevent the server getting flooded with event tracking data.

If this is an issue for you, you might like to know I've developed a workaround for this

 

Accessing the data

As with all event tracking data, you'll find this (in version 5 of GA) under Content > Events > Overview > Cohort analysis. 

When you've had this up and running for a few months you'll develop a good picture of what your customer base looks like, which will give you the potential for more insight. 

Chart your cohorts over a period of months to see how many of the customers have returned, then see if you can use lifecycle marketing techniques to target certain cohorts and get them to return. 

Update: If you want to try the alternative way of doing this, using custom variables, then do make sure you check out Jonathan Balogh's excellent detailed guide



Published: Matt Clarke Wednesday 14 December 2011, 11:54 am
Views: 8,571 times
Filed under: Google Analytics cohort analysis

(No votes yet)



Login to leave your comments

Please login

Username
Password
  Remember me
Reset password | Send activation code

Related items

How to set up event tracking in Google Analytics
How to set up event tracking in Google Analytics
Follow this simple guide and you'll be abl... no votes (No votes)
Google Analytics fast-access mode is killing GA usability
Google Analytics fast-access mode is killing GA usability
I love Google Analytics and spend many hou... no votes (No votes)
Track your Google Plus One button in Google Analytics
Track your Google Plus One button in Google Analytics
Want to add the new Google +1 button to yo... no votes (No votes)
Google Analytics 5 to include 50 custom variables?
Google Analytics 5 to include 50 custom variables?
Google Analytics power users could be in f... no votes (No votes)
16 interesting ways to use Google Analytics custom variables
16 interesting ways to use Google Analytics custom variables
Early signs suggest that Google Analytics ... 5 (1 vote) *1 comment

Recently added

What is customer retention and how do you measure it?
What is customer retention and how do you measure it?
Although it's considered one of marketing'... no votes (No votes)
Returns Management System hacking with Google Analytics
Returns Management System hacking with Google Analytics
Here's how I used Google Analytics, PHP-GA... no votes (No votes)
Improving e-commerce analytics with Universal Analytics
Improving e-commerce analytics with Universal Analytics
My recent presentation from MeasureCamp in... no votes (No votes) *2 comments
Preventing duplicate transactions inflating Google Analytics data
Preventing duplicate transactions inflating Google Analytics data
Oddly, Google Analytics doesn't include an... no votes (No votes) *6 comments

Recent comments