Created
December 6, 2011 14:38
-
-
Save aranw/1438402 to your computer and use it in GitHub Desktop.
Google Analytics Social Tracking Code
This file contains hidden or 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 (b) { | |
(function (a) { | |
"__CF" in b && "DJS" in b.__CF ? b.__CF.DJS.push(a) : "addEventListener" in b ? b.addEventListener("load", a, !1) : b.attachEvent("onload", a) | |
})(function () { | |
"FB" in b && "Event" in FB && "subscribe" in FB.Event && (FB.Event.subscribe("edge.create", function (a) { | |
_gaq.push(["_trackSocial", "facebook", "like", a]) | |
}), FB.Event.subscribe("edge.remove", function (a) { | |
_gaq.push(["_trackSocial", "facebook", "unlike", a]) | |
}), FB.Event.subscribe("message.send", function (a) { | |
_gaq.push(["_trackSocial", "facebook", "send", a]) | |
})); | |
"twttr" in b && "events" in twttr && "bind" in twttr.events && twttr.events.bind("tweet", function (a) { | |
if (a) { | |
var b; | |
if (a.target && a.target.nodeName == "IFRAME") a: { | |
if (a = a.target.src) { | |
a = a.split("#")[0].match(/[^?=&]+=([^&]*)?/g); | |
b = 0; | |
for (var c; c = a[b]; ++b) if (c.indexOf("url") === 0) { | |
b = unescape(c.split("=")[1]); | |
break a | |
} | |
} | |
b = void 0 | |
} | |
_gaq.push(["_trackSocial", "twitter", "tweet", b]) | |
} | |
}) | |
}) | |
})(window); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Credit for this code goes to @craigmdennis