summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--googleanalytics.js15
1 files changed, 10 insertions, 5 deletions
diff --git a/googleanalytics.js b/googleanalytics.js
index a6ebf6f..60661cd 100644
--- a/googleanalytics.js
+++ b/googleanalytics.js
@@ -15,19 +15,24 @@ 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)) {
+ // 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.
pageTracker._trackPageview(this.href.replace(isInternal, ''));
}
}
else {
- if (ga.trackMailto && this.href.indexOf('mailto:') == 0) {
+ if (ga.trackMailto && $(this).is("a[href^=mailto:]")) {
// Mailto link clicked.
- pageTracker._trackPageview('/mailto/' + this.href.substring(7));
+ pageTracker._trackEvent("Mails", "Click", this.href.substring(7));
}
else if (ga.trackOutgoing) {
- // External link clicked. Clean and track the URL.
- pageTracker._trackPageview('/outgoing/' + this.href.replace(/^(https?|ftp|news|nntp|telnet|irc|ssh|sftp|webcal):\/\//i, '').split('/').join('--'));
+ // External link clicked.
+ pageTracker._trackEvent("Outgoing links", "Click", this.href);
}
}
});