Created
March 15, 2019 16:50
-
-
Save ivanfgm/e1b3db4305c713e15db34566bb6a8f17 to your computer and use it in GitHub Desktop.
Evento para contar links externos a través de eventos
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 () { | |
function handleOutboundLinkClicks (event) { | |
event.preventDafault(); | |
ga('send', 'event', { | |
eventCategory: 'Outbound Link', | |
eventAction: 'click', | |
eventLabel: event.target.href, | |
hitCallback: function () { | |
window.location.href = event.target.href; | |
} | |
}); | |
} | |
var outlinks = document.querySelectorAll("[data-outlink]"); | |
for (var i = outlinks.length - 1; i >= 0; i--) { | |
outlinks[i].addEventListener("click", handleOutboundLinkClicks); | |
} | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment