Skip to content

Instantly share code, notes, and snippets.

@ortense
Created May 27, 2014 14:58
Show Gist options
  • Save ortense/ac4b37f4485ba59b5f9c to your computer and use it in GitHub Desktop.
Save ortense/ac4b37f4485ba59b5f9c to your computer and use it in GitHub Desktop.
Google Analytics Events for Twitter plugin interactions
(function(){
/**
* Twitter interaction
* @see https://dev.twitter.com/docs/tfw/events
*/
var category = 'social',
action = 'twitter';
if(twttr && twttr.events && twttr.events.bind){
twttr.events.bind('tweet', function (event) {
var label = 'tweet';
ga('send', 'event', category, action, label);
});
twttr.events.bind('click', function (event) {
var label = 'click';
ga('send', 'event', category, action, label);
});
}
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment