1(function(WGR) { 2 /** 3 * Set a cookie 4 * @param {string} name 5 * @param {string} value 6 */ 7 function setCookie(name, value) { 8 const expires = new Date(); 9 expires.setDate(expires.getDate() + 90); 10 document.cookie = name + '=' + value + '; expires=' + expires.toUTCString() + '; path=/'; 11 } 12 13 /** 14 * Fetches all tracking parameters 15 * @returns {object} 16 */ 17 function getTrackingParameters() { 18 const searchValues = [ 19 'gclid', 20 'fbclid' 21 ]; 22 23 const urlParams = new URLSearchParams(window.location.search); 24 const foundParameters = {}; 25 26 urlParams.forEach((value, key) => { 27 if (key.startsWith('utm_') || searchValues.includes(key)) { 28 foundParameters[key] = value; 29 } 30 }); 31 32 return foundParameters; 33 } 34 35 /** 36 * Fetches and sets tracking cookies 37 */ 38 function setTrackingCookies() { 39 const params = getTrackingParameters(); 40 Object.keys(params).forEach(key => setCookie(key, params[key], 90, '/')); 41 } 42 43 Object.defineProperty(WGR, 'attribution', { 44 value: Object.freeze({ 45 setTrackingCookies: setTrackingCookies, 46 }), 47 writable: false, 48 }); 49})(window.WGR = window.WGR || {});
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.