Created
June 2, 2011 16:02
-
-
Save yahelc/1004702 to your computer and use it in GitHub Desktop.
Simpler Twitter Intents / Google Analytics Script
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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