Google Analytics+ Hooks (Add additional JS)

Hi There,

I want to add some additional javascript into the Google Analytics script.

So I end up with something like this:

(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');

ga('create', 'UA-XXXXXXXX-X', 'mydomain.com');
ga('send', 'pageview');

window.onload = function() {
  var a = document.getElementsByTagName('a');
  for (i = 0; i < a.length; i++) {
    if (a[i].hostname === location.hostname) {
      if (a[i].href.match(/^https?:\/\/.+\.(zip|dmg|txt|cfg|gz|pl|pdf)$/i)) {
        a[i].setAttribute('target', '_blank');
        a[i].onclick = function() {
          ga('send', 'event', 'Downloads', 'Click', this.getAttribute('href'));
        };
      }
    }
  }
}

Is there a hook I can use to add the additional js.

The additional Js is used to track downloads.

Thank you in advance.

Michael