diff --git a/googleanalytics.js b/googleanalytics.js index f4442fe1cb2cc1ed0d09a35f0cbac24aef047b4a..689243a4189253885731a8ba2f687892aee23433 100644 --- a/googleanalytics.js +++ b/googleanalytics.js @@ -15,7 +15,17 @@ Drupal.behaviors.gaTrackerAttach = function(context) { // Is the clicked URL internal? if (isInternal.test(this.href)) { // Is download tracking activated and the file extension configured for download tracking? - if ((ga.trackDownload && isDownload.test(this.href)) || isInternalSpecial.test(this.href)) { + if (ga.trackDownload && isDownload.test(this.href)) { + if (ga.LegacyVersion) { + urchinTracker(this.href.replace(isInternal, '')); + } + else { + // Download link clicked. + var extension = isDownload.exec(this.href); + pageTracker._trackEvent("Downloads", extension[1].toUpperCase(), this.href.replace(isInternal, '')); + } + } + else if (isInternalSpecial.test(this.href)) { // Keep the internal URL for Google Analytics website overlay intact. if (ga.LegacyVersion) { urchinTracker(this.href.replace(isInternal, '')); @@ -26,13 +36,13 @@ Drupal.behaviors.gaTrackerAttach = function(context) { } } else { - if (ga.trackMailto && this.href.indexOf('mailto:') == 0) { + if (ga.trackMailto && $(this).is("a[href^=mailto:]")) { // Mailto link clicked. if (ga.LegacyVersion) { urchinTracker('/mailto/' + this.href.substring(7)); } else { - pageTracker._trackPageview('/mailto/' + this.href.substring(7)); + pageTracker._trackEvent("Mails", "Click", this.href.substring(7)); } } else if (ga.trackOutgoing) { @@ -41,7 +51,7 @@ Drupal.behaviors.gaTrackerAttach = function(context) { urchinTracker('/outgoing/' + this.href.replace(/^(https?|ftp|news|nntp|telnet|irc|ssh|sftp|webcal):\/\//i, '').split('/').join('--')); } else { - pageTracker._trackPageview('/outgoing/' + this.href.replace(/^(https?|ftp|news|nntp|telnet|irc|ssh|sftp|webcal):\/\//i, '').split('/').join('--')); + pageTracker._trackEvent("Outgoing links", "Click", this.href); } } }