Cohort analysis in Google Analytics
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,725 times
Filed under: Google Analytics cohort analysis
Login to leave your comments