Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
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