How to do Cohort Analysis in Google Analytics

New to cohorts? Check out the Introduction to Cohort Analysis for Startups.

Clearly cohort analysis is a great tool to track retention and user engagement but how do you set up your blog, game or web service to track cohort groups? Google Analytics doesn’t support cohort tracking as a standard feature. The service primarily targets traditional site navigation metrics such as visits, pageviews, traffic sources and bounce rate. In the past, most companies relied on in-house solutions to get visitor-level data – and many still do. But for those unable or unwilling to create a custom analytics application for their product there haven’t been a lot of alternatives.

Appropriately, in the last few years, a new breed of analytics services has emerged which focuses more on user engagement metrics. A few of the more popular options include Mixpanel, KISSmetrics and Kontagent – all of which include event tracking, cohort metrics, per-user funnels, real-time updates, etc.

Why Google Analytics?

Considering there are services designed specifically for user engagement tracking and customer cohort analysis, it may seem a little odd that we’re going to focus on the one that isn’t. As it turns out, there are good reasons to consider Google Analytics for cohort analysis. In fact, a strong set of standard features combined with a number of new additions makes it a rather strong competitor to the new services.

Why Google Analytics may not be as bad as you think:

Unique visitors Last year Google made a quiet but important update making the detailed analysis of unique visitors considerably more viable.
Events Google Analytics has had a competent event tracking system for several years now. A recent update allows you to use events to track goal completion.
Persistent user tracking This is critical for following cohorts. While the implementation is weak, Google Analytics does support cookie data storage.
Data timeliness Standard report data has become increasingly timely (often delayed by less than an hour) and they now offer a real-time user visit monitor.
Breadth of features Google Analytics is rapidly morphing into a Swiss Army knife of functionality, covering everything from social media tracking to website speed optimization. This level of integration isn’t available in the other options and keeps the number of tools you need to integrate and understand to a minimum.
Familiarity Everyone and their dog uses this tool so you’re probably already familiar with it; it’s relatively simple to use and available everywhere.
Free This is especially important if you’re a startup. The other options can get pricey, depending on your requirements.

For only $150,000 annually you can sign up for Google Analytics Premium which gives you 50 custom variables to play with. There have been rumors of an increase to the 5 slot limit for regular accounts for ages.

For cohort analysis, the most relevant of the above features is Google Analytics’ support for persistent user tracking. The most common and accepted way to track users as they navigate your product is to record tracking data in site cookies. You access Google Analytics cookies through a “custom variables” abstraction. Unfortunately, it’s remarkably constrained, using an awkward model where page, session and visitor-scoped custom variables are shared across only 5 “slots”. In the next section we’ll use these slots to record cohort visits.

The steps

Let’s remind ourselves what we’re trying to do. Our goal is to use the abstraction provided by Google Analytics’ five custom variables to stamp cohort-specific values in each user’s tracking cookie so that we can see, over a period of time, how well they achieve desirable business goals compared to other user groups.

Here are the steps:

Google Analytics is primarily designed around the notion of visit (not visitor) tracking. The Advanced Segments function in Google Analytics allows you to isolate visits that meet a configurable set of conditions. While the ability to slice and dice your data in almost any fashion is powerful, you won’t immediately be able to see the number of visitors that match your criteria.

  1. Decide what to track. Define what you need to store (dates, goals, etc.) and how you will partition it in the available slots.
  2. Write the data. Write the appropriate data to their cookies when visitors arrive.
  3. Segment the results. For each cohort grouping that you want to track, create an advanced segment in Google Analytics.
  4. Analyze with reports. Create cohort reports for retention or goal analysis.

Continue…

About these ads

18 thoughts on “How to do Cohort Analysis in Google Analytics

  1. Pingback: Introduction to Cohort Analysis for Startups | Jonathon Balogh

  2. Pingback: How to learn about your customer behaviour and engagement | Farbey's Notes

  3. Pingback: Quora

  4. Pingback: Quora

  5. Pingback: How Does Mixpanel Compare to Google Analytics? | Jonathon Balogh

  6. Pingback: Cohort analysis in a nutshell | A blog about behavioral economics, crowdfunding, crowdsourcing, gamification and more

  7. Great post. What I feel is missing (in GA, not in your post) is the ability to `get` a visitor-level custom variable, or alternatively, to only set a custom variable if it’s not already set.

    Unless I’m missing something obvious, that would make the implementation of cohort analysis in GA – specifically, setting the starting date – way easier. I guess you could dive into the cookies, but this sounds awful to me.

      • I wanted to only set a visitor-level customer variable if it was not already set. This way I have start date for my first time visitors.

        What I did was check if my visitor-level variable “Start Date” was set and if it wasn’t I would appoint the day’s date to this variable.

        The _gaq.push looks like this:
        _gaq.push(function() {
        var pageTracker = _gat._getTrackerByName(); // Gets the default tracker.
        var VisitorCustomVar = pageTracker._getVisitorCustomVar(1);
        var push_content = ['_setCustomVar', 1, 'Start Date', '{{ analytics_startdate }}', 1];

        if (!VisitorCustomVar) {
        return push_content;
        }

        return false;
        });

        We get the visitor custom variable with the _getVisitorCustomVar(1) function where 1 is the index of our custom variable. Then we check if this variable already exist and if it doesn’t we set a new variable(through the push_content array)

  8. Pingback: Metrics | Annotary

  9. Pingback: The Scrappy Mofo’s Guide to Advanced Segmentation | iAcquire Blog

  10. Pingback: Google Analyticsを使ったコホート分析で施策の有効性を検証する | @takatama_jp

  11. Pingback: The Scrappy Mofo’s Guide to Advanced Segmentation »

  12. I see a lot of interesting articles on your page.
    You have to spend a lot of time writing, i know how to save you a lot of time, there is a tool that creates unique, SEO friendly posts in couple of minutes, just
    search in google – k2 unlimited content

  13. Thanks for the great article. :)
    I think this is the best article I’ve seen on how to track retention data using Google analytics.

    Any idea whether it would work on mobile apps in the same manner?
    I’m guessing it will, but it would be great if can be said by someone who actually tried this.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s