1const MOBILE = 'mobile'; 2const TABLET = 'tablet'; 3const DESKTOP = 'desktop'; 4 5const CATEGORY_APPRAISAL = 'appraisal'; 6 7/** 8 * Returns a device type by match media method 9 * @returns {string} 10 */ 11const device = () => { 12 if (window.matchMedia('screen and (min-width: 992px)')) { 13 return DESKTOP; 14 } 15 16 if (window.matchMedia('screen and (min-width: 768px)')) { 17 return TABLET; 18 } 19 20 return MOBILE; 21}; 22 23 24window.KwsTracker = { 25 trackEvent: function (category, action, label, parameters = {}) { 26 window.dataLayer = window.dataLayer || []; 27 window.dataLayer.push({ 28 event: 'Intention', 29 trackAction: action, 30 trackCategory: category, 31 trackLabel: label, 32 deviceType: device(), 33 ...parameters 34 }); 35 }, 36 37 trackGoal: function (goal) { 38 window.dataLayer = window.dataLayer || []; 39 window.dataLayer.push({ 40 event: 'VirtualPageview', 41 virtualPageURL: goal, 42 deviceType: device(), 43 }); 44 }, 45 46 trackAppraisalEvent: function (action, label, parameters = {}) { 47 this.trackEvent(CATEGORY_APPRAISAL, action, label, parameters) 48 }, 49}; 50 51// Custom event to handle dataLayer push events 52window.dataLayer = new Proxy(window.dataLayer || [], { 53 set: (obj, prop, value) => { 54 if (prop !== 'length') { 55 const pushEvent = new CustomEvent('datalayerpush', { 56 detail: value 57 }); 58 59 window.dispatchEvent(pushEvent); 60 } 61 62 return Reflect.set(obj, prop, value); 63 } 64});
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.