Call us Toll-Free:
1-800-218-1525
Live ChatEmail us

 Sponsors

Tracking Retention in Google Analytics

Mike Peters, 01-29-2013
Tracking retention rates or cohort analysis, is the best way to visualize your site's addict-ability.

User retention tends to be an area where people pay the least amount of attention, but I think is one of the most important to monitor. I would argue that the single most telling metric for a great product is how many of them become dedicated, repeat users.

If you fail to retain users over time, traffic will never generate a "snow ball" effect. Your glass-ceiling becomes limited to the arbitrage difference between the cost of traffic and ad revenues.

Focus on continually improving your retention rates and you'll be well on your way to building a mega successful site.

First step is to monitor your retention rate numbers. As they say - "What doesn't get measured, Doesn't get done".

The goal is to have the data you need to generate a cohort report like this one:



In this post, I'll describe how to use Google Analytics, for cohort analysis.

Don't be fooled by Google's Returning visitors numbers

Google Analytics appears to provide information about visitor retention through the New vs. Returning visitors report.

That report shows you the proportion of returning visitors. You could set your date range for January, note the percentage of returning visitors, and then set the date range for February, hoping that the percentage of returning visitors has increased.

But what happens if you retain all your January visitors, but drive a ton of new visitors to the site in February? Your proportion of returning-to-new visitors will go down even though you're retaining visitors!

Additionally, if your funnel involves users leaving the site (to "Facebook-Connect" for example), Google Analytics could confuse that with a user leaving the site.

Tagging visitors

For proper cohort analysis, we need a way to "tag" users, segmenting them into groups based on the date of first visit.

We'll then be able to look at the group of new users generated on a given month and see how long they stuck around:



Google Analytics custom variables and events, lets us put it all together.

Step 1 - Install Google Analytics

Signup for Google Analytics (it's free) and create an account for your site.

Add the Google Analytics code to all pages on your site.

Generally this means adding the code to your footer include file.

Step 2 - Pulse script

Save this script under the root folder of your site:

pulse.php

putenv
('TZ=America/New_York');
header('Content-type: application/json');

die(
"if(typeof pulseCallback=='function')".
' pulseCallback({"pulse":"'.date('Y-m-d').'"});');

Note that I'm assuming your server supports PHP. If you're using a different server-side scripting language, find a geek who can help or contact us.

Step 3 - Store custom variable in Google Analytics

Add this javascript code to the footer of all pages:
function jsCreateCookie(name,value,days){if(days){var date=new Date();date.setTime(date.getTime()+(days*24*60*60*1000));var expires="; expires="+date.toGMTString()}else var expires="";document.cookie=name+"="+value+expires+"; path=/"}
function jsReadCookie(name){var nameEQ=name+"=";var ca=document.cookie.split(';');for(var i=0;i!=ca.length;i++){var c=ca[i];while(c.charAt(0)==' ')c=c.substring(1,c.length);if(c.indexOf(nameEQ)==0)return c.substring(nameEQ.length,c.length)}return null}
function jsGetCookie(cvar, cval) { if (cval == undefined) cval = ''; return (jsReadCookie(cvar) != null && jsReadCookie(cvar) != '') ? jsReadCookie(cvar) : cval; }

try {
var checkpulse = jsGetCookie('checkpulse');
if (!checkpulse) {
// get timestamp
var s = document.createElement('script'); s.type = 'text/javascript'; s.src = 'http://YOURDOMAIN.com/pulse.php'; s.async = true;
(document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(s);
} else {
channel = ""; // Update when using channels
$(document).ready(function () { _gaq.push(['_trackEvent', 'Pulse', checkpulse, 'Channel #'+channel]); });
}
} catch(err){}
function pulseCallback(o) {
jsCreateCookie('checkpulse', o.pulse, 365);
}

What we're doing here is - on every page load, check if the user was already tagged with a "create date".

If user not tagged yet - it's a new user, we connect to the server's pulse.php script and fetch today's date. The date is then stored in a local cookie named "checkpulse".

Finally, we pass the event to Google Analytics, incrementing a count for our user's "create date".

Crunching the numbers

Congratulations! Now you can finally track your real retention rates and build a cohort chart.

Login to Google Analytics, open "Traffic Sources", then "Events" - "Top Events"

Select the date range starting with the first month you're tracking (January in the example above) through today. Change the period to "Month" and select "Unique Events":



Hover above the chart and record the numbers for each of the months



Download sample Cohort report and populate it with your data. Pay attention to your user's average life time and variations in month-to-month retention rates.

Know your numbers.

Use your cohort report as a compass for whether or not you've created a great product that users love.
Enjoyed this post?

Subscribe Now to receive new posts via Email as soon as they come out.

 Comments
Post your comments












Note: No link spamming! If your message contains link/s, it will NOT be published on the site before manually approved by one of our moderators.



About Us  |  Contact us  |  Privacy Policy  |  Terms & Conditions