Skip to content

Instantly share code, notes, and snippets.

@shaneog
Forked from yahelc/gist:1004702
Last active August 29, 2015 13:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shaneog/8977948 to your computer and use it in GitHub Desktop.
Save shaneog/8977948 to your computer and use it in GitHub Desktop.
(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]] : "" ;
dataLayer.push({
'event': 'socialInt',
'socialNetwork': 'Twitter',
'socialAction': intent_event.type,
'socialTarget': label
});
}
});
}
}
}());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment