1// This javascript tags file downloads and external links in Google Analytics. 2// You need to be using the Google Analytics New Tracking Code (ga.js) 3// for this script to work. 4// To use, place this file on all pages just above the Google Analytics tracking code. 5// All outbound links and links to non-html files should now be automatically tracked. 6// 7// This script has been provided by Goodwebpractices.com 8// Thanks to ShoreTel, MerryMan and Colm McBarron 9// 10// www.goodwebpractices.com 11// VKI has made changes as indicated below. 12 13if (document.getElementsByTagName) { 14 // Initialize external link handlers 15 var hrefs = document.getElementsByTagName("a"); 16 for (var l = 0; l < hrefs.length; l++) { 17 // try {} catch{} block added by erikvold VKI 18 try{ 19 //protocol, host, hostname, port, pathname, search, hash 20 if (hrefs[l].protocol == "mailto:") { 21 startListening(hrefs[l],"click",trackMailto); 22 } else if (hrefs[l].hostname == location.host) { 23 var path = hrefs[l].pathname + hrefs[l].search; 24 var isDoc = path.match(/\.(?:doc|eps|jpg|png|svg|xls|ppt|pdf|xls|zip|txt|vsd|vxd|js|css|rar|exe|wma|mov|avi|wmv|mp3)($|\&|\?)/); 25 if (isDoc) { 26 startListening(hrefs[l],"click",trackExternalLinks); 27 } 28 } else if (!hrefs[l].href.match(/^javascript:/)) { 29 startListening(hrefs[l],"click",trackExternalLinks); 30 } 31 } 32 catch(e){ 33 continue; 34 } 35 } 36} 37 38function startListening (obj,evnt,func) { 39 if (obj.addEventListener) { 40 obj.addEventListener(evnt,func,false); 41 } else if (obj.attachEvent) { 42 obj.attachEvent("on" + evnt,func); 43 } 44} 45 46function trackMailto (evnt) { 47 var href = (evnt.srcElement) ? evnt.srcElement.href : this.href; 48 var mailto = "/mailto/" + href.substring(7); 49 if (typeof(pageTracker) == "object") pageTracker._trackPageview(mailto); 50} 51 52function trackExternalLinks (evnt) { 53 var e = (evnt.srcElement) ? evnt.srcElement : this; 54 while (e.tagName != "A") { 55 e = e.parentNode; 56 } 57 var lnk = (e.pathname.charAt(0) == "/") ? e.pathname : "/" + e.pathname; 58 if (e.search && e.pathname.indexOf(e.search) == -1) lnk += e.search; 59 if (e.hostname != location.host) lnk = "/external/" + e.hostname + lnk; 60 if (typeof(pageTracker) == "object") pageTracker._trackPageview(lnk); 61}
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.