Sue Feng Design

‹ Back to blog

Google Analytics RSS Feed Tracking

We all know about Feed Burner, but did you know you can use Google Analytics to track RSS Feed subscribers too? You can apend a random number for each person who subscribes, and keep track of the number of times they view your subscription. It’s not too difficult to implement either. It works especially well if you have a PHP generated RSS feed. If you don’t, that’s not a big deal. Also, you’ll want to create a Google Analytics for your RSS feed page.

rss analytics

Here’s the bit of code you’ll want to add to the bottom of your RSS page, if it’s a PHP file:

$var_utmac='UA-########-#'; //enter the new urchin code
$var_utmhn='http://example.com/rss.php'; //enter your rss url
$var_utmn=rand(1000000000,9999999999);//random request number
$var_cookie=rand(10000000,99999999);//random cookie number
$var_random=rand(1000000000,2147483647); //number under 2147483647
$var_today=time(); //today
$var_referer=$_SERVER['HTTP_REFERER']; //referer url

$var_uservar='-'; //enter your own user defined variable
$var_utmp='/rss'.$_SERVER['REMOTE_ADDR']; //this example adds a fake page request to the (fake) rss directory (the viewer IP to check for absolute unique RSS readers)


$handle = fopen ($urchinUrl, "r");
$test = fgets($handle);


If it’s not a PHP file, you can use javascript instead, like this:

var var_utmac='UA-########-#'; //enter the new urchin code
var var_utmhn='http://example.com/rss.php'; //enter your rss url
var var_utmn=rand(1000000000,9999999999);//random request number
var var_cookie=rand(10000000,99999999);//random cookie number
var var_random=rand(1000000000,2147483647); //number under 2147483647
var var_today=time(); //today
var var_referer=_SERVER['HTTP_REFERER']; //referer url

var var_uservar='-'; //enter your own user defined variable
var var_utmp='/rss'+_SERVER['REMOTE_ADDR']; //this example adds a fake page request to the (fake) rss directory (the viewer IP to check for absolute unique RSS readers)

var urchinUrl='http://www.google-analytics.com/__utm.gif?utmwv=1&utmn='+var_utmn+'&utmsr=-&utmsc=-&utmul=-&utmje=0&utmfl=-&utmdt=-&utmhn='+var_utmhn+'&utmr='+var_referer+'&utmp='+var_utmp+'&utmac='+var_utmac+'&utmcc=__utma%3D'+var_cookie+'.'+var_random+'.'+var_today+'.'+var_today+'.'+var_today+'.2%3B%2B__utmb%3D'+var_cookie+'%3B%2B__utmc%3D'+var_cookie+'%3B%2B__utmz%3D'+var_cookie+'.'+var_today+'.2.2.utmccn%3D(direct)%7Cutmcsr%3D(direct)%7Cutmcmd%3D(none)%3B%2B__utmv%3D'+var_cookie+'.'+var_uservar+'%3B';

var handle = fopen (urchinUrl, "r");
var test = fgets(handle);

In both cases, you need to put in your urchin (UA-########-#) number and your RSS feed url. The user’s ip address is appended at the end of the RSS feed url as an identification number for each person. Then Google can track the number of times that person/url with ip address appended views the RSS feed page.

rss analytics 2

Let me know if it works or doesn’t work if you decide to try it. I’ve been using it for quite some time and it works well for me.

Posted on: September 9, 2012Categories: TutorialsTags: coding
‹ Back to blog