Skip to content

Instantly share code, notes, and snippets.

@andregoncalves
Created July 6, 2011 17:59
Show Gist options
  • Save andregoncalves/1067892 to your computer and use it in GitHub Desktop.
Save andregoncalves/1067892 to your computer and use it in GitHub Desktop.
Google analytics social events tracking
trackSocialEvents: function() {
// Track Facebook
FB.Event.subscribe('edge.create', function(targetUrl) {
_gaq.push(['_trackSocial', 'facebook', 'like', targetUrl]);
});
// Track Twitter
twttr.events.bind('tweet', function(event) {
if (event) {
var targetUrl;
if (event.target && event.target.nodeName == 'IFRAME') {
targetUrl = extractParamFromUri(event.target.src, 'url');
}
_gaq.push(['_trackSocial', 'twitter', 'tweet', targetUrl]);
}
);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment