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…

39 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.

  14. I read a lot of interesting content here. Probably you spend a lot
    of time writing, i know how to save you a lot of work,
    there is an online tool that creates unique, google friendly posts in minutes, just search in google – laranitas free
    content source

  15. Have you ever considered writing an e-book or guest authoring on other sites?
    I have a blog centered on the same information you discuss and would love to have you share some stories/information. I know my audience would value your work.
    If you’re even remotely interested, feel free to shoot me an e mail.

  16. Hello there! I know this is kinda off topic but I was wondering which
    blog platform are you using for this website? I’m getting sick and tired of WordPress because I’ve had problems
    with hackers and I’m looking at options for another platform.

    I would be fantastic if you could point me in the direction of a good platform.

  17. Good day! Do you know if they make any plugins to help with SEO?
    I’m trying to get my blog to rank for some targeted keywords but I’m not seeing very good success.
    If you know of any please share. Thanks!

  18. Just wish to say your article is as astonishing.

    The clearness to your post is just excellent and that i
    could assume you’re a professional in this subject.
    Well together with your permission let me to grab your feed
    to keep up to date with approaching post. Thank you one million and please
    keep up the gratifying work.

  19. Have you ever considered writing an e-book or
    guest authoring on other websites? I have a blog centered on the same topics you discuss and would love to have you share some
    stories/information. I know my viewers would value your work.
    If you’re even remotely interested, feel free to shoot
    me an e-mail.

  20. hello there and thank you for your info – I have definitely picked up
    anything new from right here. I did however
    expertise several technical points using this website, since I experienced to reload
    the web site lots of times previous to I could get it to load properly.

    I had been wondering if your web hosting is OK? Not that I am complaining, but sluggish
    loading instances times will sometimes affect your placement in google and could damage your quality
    score if advertising and marketing with Adwords.
    Well I’m adding this RSS to my email and can look out for a lot more of
    your respective fascinating content. Make sure you update this again very soon.

  21. An outstanding share! I’ve just forwarded this onto a co-worker who
    had been doing a little homework on this. And he actually bought me dinner simply because I discovered it for him…

    lol. So let me reword this…. Thanks for the meal!! But yeah, thanks for spending the time to discuss this subject here on your internet site.

  22. That is very fascinating, You’re an overly skilled blogger.
    I have joined your feed and sit up for seeking more of your
    fantastic post. Also, I’ve shared your website in my social networks

  23. Great post. I was checking continuously this blog and I am impressed!
    Very helpful info specially the last part 🙂 I care for such info a lot.
    I was seeking this particular information for a long time.
    Thank you and best of luck.

  24. Pingback: User Behavioural Analytics – Yong Liu – Writing for Learning and Sharing

  25. I don’t know if it’s just me or if everybody else experiencing problems with your website.
    It looks like some of the text in your posts are running off the screen. Can somebody else please comment and let me know if this is happening to them as well?
    This may be a problem with my internet browser because I’ve had this happen previously.

    Thanks

  26. Pingback: User Behavioural Analytics – 未来科技,今日生活

Leave a comment