Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var addTrackToLink = function() {
- var anchor = new RegExp(location.href + "#.*?");
- var js = /^javascript\:/;
- return function(link) {
- var handler = link.readAttribute('onclick');
- var href = link.href;
- if (handler === null && !anchor.test(href) && !js.test(href)) {
- var action = href.match(/http?:\/\/([^\/]+)\//)[1];
- link.writeAttribute('onclick', "javascript:_gaq.push(['_trackEvent', 'outbound-article', '" + action + "'])");
- }
- };
- }();
- document.observe('dom:loaded', function(event) {
- $$('a').each(addTrackToLink);
- }, false);
- document.observe('DOMNodeInserted', function(event) {
- $(event.target).select('a').each(addTrackToLink);
- }, false);
Add Comment
Please, Sign In to add comment