summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorhass2009-03-04 07:25:47 (GMT)
committer hass2009-03-04 07:25:47 (GMT)
commita2f9d0856a51a8ff53ef3c45be518da2c8c4bf49 (patch)
tree97895c58f01f4119f58f02ac196b4bc51b65ffb1
parent79a03b9a18564b9d45a3a32459d72970730cb7f4 (diff)
#357944: Support for try / catch
-rw-r--r--googleanalytics.js52
1 files changed, 23 insertions, 29 deletions
diff --git a/googleanalytics.js b/googleanalytics.js
index c6f2f91..b68d7e3 100644
--- a/googleanalytics.js
+++ b/googleanalytics.js
@@ -12,36 +12,30 @@ Drupal.behaviors.gaTrackerAttach = function(context) {
// Expression to check for download links.
var isDownload = new RegExp("\\.(" + ga.trackDownloadExtensions + ")$", "i");
- // 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)) {
- // Download link clicked.
- var extension = isDownload.exec(this.href);
- try{
- pageTracker._trackEvent("Downloads", extension[1].toUpperCase(), this.href.replace(isInternal, ''));
- } catch(err) {}
+ try {
+ // 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)) {
+ // 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 (isInternalSpecial.test(this.href)) {
- // Keep the internal URL for Google Analytics website overlay intact.
- try{
- pageTracker._trackPageview(this.href.replace(isInternal, ''));
- } catch(err) {}
+ else {
+ if (ga.trackMailto && $(this).is("a[href^=mailto:]")) {
+ // Mailto link clicked.
+ pageTracker._trackEvent("Mails", "Click", this.href.substring(7));
+ }
+ else if (ga.trackOutgoing) {
+ // External link clicked.
+ pageTracker._trackEvent("Outgoing links", "Click", this.href);
+ }
}
- }
- else {
- if (ga.trackMailto && $(this).is("a[href^=mailto:]")) {
- // Mailto link clicked.
- try{
- pageTracker._trackEvent("Mails", "Click", this.href.substring(7));
- } catch(err) {}
- }
- else if (ga.trackOutgoing) {
- // External link clicked.
- try{
- pageTracker._trackEvent("Outgoing links", "Click", this.href);
- } catch(err) {}
- }
- }
+ } catch(err) {}
});
}