| [ Index ] |
PHP Cross Reference of Drupal 6 (yi-drupal) |
[Summary view] [Print] [Text view]
1 2 $(document).ready(function() { 3 4 // Attach onclick event to document only and catch clicks on all elements. 5 $(document.body).click(function(event) { 6 // Catch only the first parent link of a clicked element. 7 $(event.target).parents("a:first,area:first").andSelf().filter("a,area").each(function() { 8 9 var ga = Drupal.settings.googleanalytics; 10 // Expression to check for absolute internal links. 11 var isInternal = new RegExp("^(https?):\/\/" + window.location.host, "i"); 12 // Expression to check for special links like gotwo.module /go/* links. 13 var isInternalSpecial = new RegExp("(\/go\/.*)$", "i"); 14 // Expression to check for download links. 15 var isDownload = new RegExp("\\.(" + ga.trackDownloadExtensions + ")$", "i"); 16 17 // Is the clicked URL internal? 18 if (isInternal.test(this.href)) { 19 // Is download tracking activated and the file extension configured for download tracking? 20 if (ga.trackDownload && isDownload.test(this.href)) { 21 // Download link clicked. 22 var extension = isDownload.exec(this.href); 23 _gaq.push(["_trackEvent", "Downloads", extension[1].toUpperCase(), this.href.replace(isInternal, '')]); 24 } 25 else if (isInternalSpecial.test(this.href)) { 26 // Keep the internal URL for Google Analytics website overlay intact. 27 _gaq.push(["_trackPageview", this.href.replace(isInternal, '')]); 28 } 29 } 30 else { 31 if (ga.trackMailto && $(this).is("a[href^=mailto:],area[href^=mailto:]")) { 32 // Mailto link clicked. 33 _gaq.push(["_trackEvent", "Mails", "Click", this.href.substring(7)]); 34 } 35 else if (ga.trackOutgoing && this.href) { 36 if (ga.trackOutboundAsPageview) { 37 // Track all external links as page views after URL cleanup. 38 // Currently required, if click should be tracked as goal. 39 _gaq.push(["_trackPageview", '/outbound/' + this.href.replace(/^(https?|ftp|news|nntp|telnet|irc|ssh|sftp|webcal):\/\//i, '').split('/').join('--')]); 40 } 41 else { 42 // External link clicked. 43 _gaq.push(["_trackEvent", "Outbound links", "Click", this.href]); 44 } 45 } 46 } 47 }); 48 }); 49 });
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated: Mon Jul 9 18:01:44 2012 | Cross-referenced by PHPXref 0.7 |