Advertisement
Guest User

Untitled

a guest
Oct 16th, 2019
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.27 KB | None | 0 0
  1. <script>
  2. function _gaLt(event){
  3. var el = event.srcElement || event.target;
  4.  
  5. /* Loop up the tree through parent elements if clicked element is not a link (eg: an image inside a link) */
  6. while(el && (typeof el.tagName == 'undefined' || el.tagName.toLowerCase() != 'a' || !el.href))
  7. el = el.parentNode;
  8.  
  9. if(el && el.href){
  10. if(el.href.indexOf(location.host) == -1){ /* external link */
  11. ga("send", "event", "Outgoing Links", el.href, document.location.pathname + document.location.search);
  12. /* if target not set then delay opening of window by 0.5s to allow tracking */
  13. if(!el.target || el.target.match(/^_(self|parent|top)$/i)){
  14. setTimeout(function(){
  15. document.location.href = el.href;
  16. }.bind(el),500);
  17. /* Prevent standard click */
  18. event.preventDefault ? event.preventDefault() : event.returnValue = !1;
  19. }
  20. }
  21.  
  22. }
  23. }
  24.  
  25. /* Attach the event to all clicks in the document after page has loaded */
  26. var w = window;
  27. w.addEventListener ? w.addEventListener("load",function(){document.body.addEventListener("click",_gaLt,!1)},!1)
  28. : w.attachEvent && w.attachEvent("onload",function(){document.body.attachEvent("onclick",_gaLt)});
  29.  
  30. </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement