1// $Id: googleanalytics.js,v 1.9.2.4 2010/09/19 11:39:20 hass Exp $ 2 3$(document).ready(function() { 4 5 // Attach onclick event to document only and catch clicks on all elements. 6 $(document.body).click(function(event) { 7 // Catch only the first parent link of a clicked element. 8 $(event.target).parents("a:first,area:first").andSelf().filter("a,area").each(function() { 9 10 var ga = Drupal.settings.googleanalytics; 11 // Expression to check for absolute internal links. 12 var isInternal = new RegExp("^(https?):\/\/" + window.location.host, "i"); 13 // Expression to check for special links like gotwo.module /go/* links. 14 var isInternalSpecial = new RegExp("(\/go\/.*)$", "i"); 15 // Expression to check for download links. 16 var isDownload = new RegExp("\\.(" + ga.trackDownloadExtensions + ")$", "i"); 17 18 // Is the clicked URL internal? 19 if (isInternal.test(this.href)) { 20 // Is download tracking activated and the file extension configured for download tracking? 21 if (ga.trackDownload && isDownload.test(this.href)) { 22 // Download link clicked. 23 var extension = isDownload.exec(this.href); 24 _gaq.push(["_trackEvent", "Downloads", extension[1].toUpperCase(), this.href.replace(isInternal, '')]); 25 } 26 else if (isInternalSpecial.test(this.href)) { 27 // Keep the internal URL for Google Analytics website overlay intact. 28 _gaq.push(["_trackPageview", this.href.replace(isInternal, '')]); 29 } 30 } 31 else { 32 if (ga.trackMailto && $(this).is("a[href^=mailto:],area[href^=mailto:]")) { 33 // Mailto link clicked. 34 _gaq.push(["_trackEvent", "Mails", "Click", this.href.substring(7)]); 35 } 36 else if (ga.trackOutgoing && this.href) { 37 // External link clicked. 38 _gaq.push(["_trackEvent", "Outgoing links", "Click", this.href]); 39 } 40 } 41 42 }); 43 }); 44});
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.