Implement Google Analytics server side without JavaScript to track RSS and XML based content

If you've ever been frustrated at the need for developers to add javascript tracking code, or you simply want to track pages like RSS and mobile pages where javascript is not allowed, then the following solution is for you.

We've done several server side solutions like this, such as the integration of phone calls into Google Analytics directly from the phone routing server (stay tuned for more!). I was reading through some articles researching and i came across an elegant post that i thought i should share:

http://www.vdgraaf.info/google-analytics-without-javascript.html

The PHP code to fake the image request for Google is as follows (also found at http://www.vdgraaf.info/wp-content/uploads/tracker.txt), although a similar technique can be used for Omniture or other platforms. This post is pretty old, but the code should still be fine, the principle is definitely still ok! 

Oh and this is also useful if you want to add other information to your Analytics, but you want to keep it from prying eyes! If you find this post useful, you may also want to check out one of our posts on network packet sniffing, which is becoming a serious alternative to javascript page tagging. See http://blog.datalicious.com/atomic-labs-pion-implementing-omniture-withou 

 

For more help with these types of integrations, contact us at insights@datalicious.com

<?php
$var_utmac='UA-000000-1'; //enter the new urchin code
$var_utmhn='yourdomain.com'; //enter your domain
$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='tracker/'.$_GET['url'].'.'.$_GET['filetype']; //this example adds a fake file request to the (fake) tracker directory (the image/pdf filename).

$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';
 
$handle = fopen ($urchinUrl, "r");
$test = fgets($handle);
fclose($handle);

switch ($_GET['filetype']){
	case 'jpg':
	header('Content-Type: image/jpeg');
	break;
	case 'gif':
	header('Content-type: image/gif');
	break;
	case 'pdf':
	header('Content-type: application/pdf');
	break;
	// add your own content types where needed
}

$imageurl = fopen ('http://www.yourdomain.com/'.$_GET['url'].'.'.$_GET['filetype'], "r"); //this is where the real file should be located
while (!feof ($imageurl)) {
	$image = fgets($imageurl, 4096);
	echo $image;
}
fclose($imageurl);
?>

 

Will Twitter be the death of RSS feeds?

It seems to me that more and more businesses now have corporate twitter accounts and given that most blog publishing platforms now have Twitter integrations, this has become the channel of choice to follow business news updates rather than RSS. The below Google Trends search term data doesn't prove that but at least supports the theory to some extend. Your thoughts?

Click on the below link to see the original Google Trends chart
http://www.google.com/trends?q=twitter%2C+rss&ctab=0&geo=au&geor=all&date=all&sort=0


Alertbox: Distributing Content Through Social Networks and RSS

Great research from Jakob Nielsen on how business users interact with social networks, I especially like the part on 'overly frequent postings' which really annoy me (and I hope we're not in the same category).

Summary: Users like the simplicity of messages that pass into oblivion over time, but were frequently frustrated by unscannable writing, overly frequent postings, and their inability to locate companies on social networks.

Some key insights form the article

  • Users prefer casual style for business messages on social networks
  • RSS feeds are seen as more trustworthy
  • RSS feeds are checked at work, social networks from home
  • Only 6% of users accessed corporate social networks from mobiles
  • People like a single stream of news that pushes old stuff down
  • Users are unlikely to search for old messages or scroll down
  • Posting frequency and expectations are tied to the service
  • If you post too rarely, your material will drift out of users' time-streams
  • If you post too much, you'll crowd out other messages
  • Three great motivators are fear, greed (deals), exclusivity (latest news)
  • Sites that are not updated regularly give a bad impression
  • Users don't actively seek out companies in social networks
  • There's usually another trigger such as recommendations (re-tweets!)
  • Overall message usefulness still scores low but trustworthiness high
  • Useful messages have substance, are timely, provided expected info
  • Trustworthiness is influenced by clear user names and logos
  • The shorter the message, the more important the writing

Read the original article here
http://www.useit.com/alertbox/streams-feeds.html

Or buy the research report here (and email me a copy please)
http://www.nngroup.com/reports/streams/