Skip to content

Instantly share code, notes, and snippets.

@yahelc
Created June 2, 2011 16:02
Show Gist options
  • Save yahelc/1004702 to your computer and use it in GitHub Desktop.
Save yahelc/1004702 to your computer and use it in GitHub Desktop.
Simpler Twitter Intents / Google Analytics Script
(function(){
var event_names = {
"click" : "" ,
"tweet" : "",
"retweet" : "source_tweet_id",
"follow" : "screen_name",
"favorite" : "tweet_id"
};
for(var event_name in event_names)
{
if(event_names.hasOwnProperty(event_name)){
twttr.events.bind(event_name, function(intent_event){
if(intent_event)
{
var label = intent_event.type==="click" ? intent_event.region : (intent_event.data) ? intent_event.data[event_names[intent_event.type]] : "" ;
_gaq.push(["_trackEvent", "twitter_web_intents", intent_event.type, label ]);
}
});
}
}
}());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment