summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorhass2008-11-25 22:52:44 (GMT)
committer hass2008-11-25 22:52:44 (GMT)
commit93f5ad2c35b94f58cba2c7729171c18328756972 (patch)
treef046100dfd635bf3eb1b84bfb03ececa75c59505
parent2fd739edf8b8caa0ea663bcf758043f165c9bbc4 (diff)
#328562: New Download, Mail and Outgoing links tracking with Events
-rw-r--r--googleanalytics.js18
1 files changed, 14 insertions, 4 deletions
diff --git a/googleanalytics.js b/googleanalytics.js
index f4442fe..689243a 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);
}
}
}