matchboxdesigngroup / universal-analytics

A WordPress plugin that provides a simple method to add Google's Universal Analytics JavaScript tracking code to your WordPress website.
GNU General Public License v2.0
0 stars 0 forks source link

Track events (Downloads, Mailto & Outbound URLs) option breaks IE8 #2

Open grimicorn opened 9 years ago

grimicorn commented 9 years ago

It has to do with this chunk and indexOf not being supported correctly in IE8, I think...

<script type="text/javascript">
    jQuery(document).ready(function(e) {
    jQuery('a').click(function(e) {
        var $this = jQuery(this);
        var href = $this.prop('href').split('?')[0];
        var ext = href.split('.').pop();
        if ('xls,xlsx,doc,docx,ppt,pot,pptx,pdf,pub,txt,zip,rar,tar,7z,exe,wma,mov,avi,wmv,wav,mp3,midi,csv,tsv,jar,psd,pdn,ai,pez,wwf'.split(',').indexOf(ext) !== -1) {       
        ga('send', 'event', 'Download', ext, href);
      }
      if (href.toLowerCase().indexOf('mailto:') === 0) {
        ga('send', 'event', 'Mailto', href.substr(7));
      }
      if ((this.protocol === 'http:' || this.protocol === 'https:') && this.hostname.indexOf(document.location.hostname) === -1) {
        ga('send', 'event', 'Outbound', this.hostname, this.pathname);
      }
    });
  });
</script>