1(function (context, trackingId, options) { 2 const history = context.history; 3 const doc = document; 4 const nav = navigator || {}; 5 const storage = localStorage; 6 const encode = encodeURIComponent; 7 const pushState = history.pushState; 8 const typeException = 'exception'; 9 const generateId = () => Math.random().toString(36); 10 const getId = () => { 11 if (!storage.cid) { 12 storage.cid = generateId() 13 } 14 return storage.cid; 15 }; 16 const serialize = (obj) => { 17 var str = []; 18 for (var p in obj) { 19 if (obj.hasOwnProperty(p)) { 20 if(obj[p] !== undefined) { 21 str.push(encode(p) + "=" + encode(obj[p])); 22 } 23 } 24 } 25 return str.join("&"); 26 }; 27 const track = ( 28 type, 29 eventCategory, 30 eventAction, 31 eventLabel, 32 eventValue, 33 exceptionDescription, 34 exceptionFatal 35 ) => { 36 const url = 'https://www.google-analytics.com/collect'; 37 const data = serialize({ 38 v: '1', 39 ds: 'web', 40 aip: options.anonymizeIp ? 1 : undefined, 41 tid: trackingId, 42 cid: getId(), 43 t: type || 'pageview', 44 sd: options.colorDepth && screen.colorDepth ? `${screen.colorDepth}-bits` : undefined, 45 dr: doc.referrer || undefined, 46 dt: doc.title, 47 dl: doc.location.origin + doc.location.pathname + doc.location.search, 48 ul: options.language ? (nav.language || "").toLowerCase() : undefined, 49 de: options.characterSet ? doc.characterSet : undefined, 50 sr: options.screenSize ? `${(context.screen || {}).width}x${(context.screen || {}).height}` : undefined, 51 vp: options.screenSize && context.visualViewport ? `${(context.visualViewport || {}).width}x${(context.visualViewport || {}).height}` : undefined, 52 ec: eventCategory || undefined, 53 ea: eventAction || undefined, 54 el: eventLabel || undefined, 55 ev: eventValue || undefined, 56 exd: exceptionDescription || undefined, 57 exf: typeof exceptionFatal !== 'undefined' && !!exceptionFatal === false ? 0 : undefined, 58 }); 59 60 if(nav.sendBeacon) { 61 nav.sendBeacon(url, data) 62 } else { 63 var xhr = new XMLHttpRequest(); 64 xhr.open("POST", url, true); 65 xhr.send(data); 66 } 67 }; 68 const trackEvent = (category, action, label, value) => track('event', category, action, label, value); 69 const trackException = (description, fatal) => track(typeException, null, null, null, null, description, fatal); 70 history.pushState = function (state) { 71 if (typeof history.onpushstate == "function") { 72 history.onpushstate({ state: state }); 73 } 74 setTimeout(track, options.delay || 10); 75 return pushState.apply(history, arguments); 76 } 77 track(); 78 context.ma = { 79 trackEvent, 80 trackException 81 } 82})(window, "UA-18006493-1", { 83 anonymizeIp: true, 84 colorDepth: true, 85 characterSet: true, 86 screenSize: true, 87 language: true 88});
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.