Tracking Facebook OpenGraph Referrals in Google Analytics

Facebook Insights aren’t always predictable, and don’t give you an accurate picture of how much of your traffic is coming from FB. You can track this with the following code snippet:

window.param = function(name) {
     return decodeURIComponent((new RegExp('[?|&]' + name + '=' + '([^&;]+?)(&|#|;|$)').exec(location.search)||[,""])[1].replace(/\+/g, '%20'))||null;
 } 
var ref = param("fb_ref"),
source = param("fb_source");
source && _gaq.push(['_trackEvent', "FB", source, ref]);
Advertisements

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

%d bloggers like this: