1(function($, window){ 2 'use strict'; 3 4 const $body = $('body'); 5 6 // ---------------------------------------- Google GTAG ---------------------------------------- 7 window.dataLayer = window.dataLayer || []; 8 function gtag(){dataLayer.push(arguments);} 9 10 // set consent defaults in the data layer 11 gtag('consent', 'default', { 12 'ad_user_data': 'denied', 13 'ad_personalization': 'denied', 14 'ad_storage': 'denied', 15 'analytics_storage': 'denied', 16 'wait_for_update': 500, 17 }); 18 19 gtag('js', new Date()); 20 21 // Universal Analytic 22 gtag('config', 'UA-39626407-1', { 23 //tracking version (increase if we make breaking change to the checkout flow etc.) 24 'dimension1': '1', 25 //anonymize IP address for GDPR compliance 26 'anonymize_ip': true 27 }); 28 29 // GA4 30 gtag('config', 'G-2YW6NFDJL8'); 31 32 // pass information about ad clicks through URL parameters 33 gtag('set', 'url_passthrough', true); 34 35 const gtagData = $body.data('gtag'); 36 37 if (typeof gtagData !== 'undefined' && gtagData.length !== 0) { 38 for (let i = 0; i < gtagData.length; i++) { 39 gtag.apply(null, gtagData[i]); 40 } 41 } 42 43 // ---------------------------------------- /Google ---------------------------------------- 44 45 // ---------------------------------------- Bing UET ---------------------------------------- 46 window.uetq = window.uetq || []; 47 window.uetq.push('consent', 'default', { 48 'ad_storage': 'denied' 49 }); 50 51 // (function (w, d, t, r, u) { 52 // let f, n, i; 53 // // noinspection CommaExpressionJS,JSValidateTypes 54 // w[u] = w[u] || [], f = function () { 55 // let o = {ti: "85082474", enableAutoSpaTracking: true}; 56 // // noinspection CommaExpressionJS,JSUnresolvedReference 57 // o.q = w[u], w[u] = new UET(o), w[u].push("pageLoad") 58 // }, n = d.createElement(t), n.src = r, n.async = 1, n.onload = n.onreadystatechange = function () { 59 // let s = this.readyState; 60 // // noinspection CommaExpressionJS 61 // s && s !== "loaded" && s !== "complete" || (f(), n.onload = n.onreadystatechange = null) 62 // }, i = d.getElementsByTagName(t)[0], i.parentNode.insertBefore(n, i) 63 // })(window, document, "script", "//bat.bing.com/bat.js", "uetq"); 64 // 65 // const uetData = $body.data('uet'); 66 // 67 // if (typeof uetData !== 'undefined' && uetData.length !== 0) { 68 // for (const uet of uetData) { 69 // window.uetq.push(...uet); 70 // } 71 // } 72 73 // ---------------------------------------- /Bing ---------------------------------------- 74 75 // ---------------------------------------- Adalyser ---------------------------------------- 76 let adalyserTrackerInitiated = false; 77 78 const adalyserTrackerInitiate = () => { 79 if (adalyserTrackerInitiated) { 80 return; 81 } 82 83 adalyserTrackerInitiated= true; 84 85 (function(clientId) { 86 if(window["__adal_disable_" + clientId]) { return; } 87 (function(windowAlias, documentAlias, trackerName) { 88 if (!windowAlias[trackerName]) { 89 windowAlias.GlobalAdalyserNamespace = windowAlias.GlobalAdalyserNamespace 90 || []; 91 windowAlias.GlobalAdalyserNamespace.push(trackerName); 92 windowAlias[trackerName] = function() { 93 (windowAlias[trackerName].q = windowAlias[trackerName].q || []).push(arguments) 94 }; 95 windowAlias[trackerName].q = windowAlias[trackerName].q || []; 96 var nel = documentAlias.createElement("script"), 97 fel = documentAlias.getElementsByTagName("script")[0]; 98 nel.async = 1; 99 nel.src = "//c5.adalyser.com/adalyser.js?cid=" + clientId; 100 fel.parentNode.insertBefore(nel, fel) 101 } 102 }(window, document, "adalyserTracker")); 103 window.adalyserTracker("create", { 104 campaignCookieTimeout: 15552000, 105 conversionCookieTimeout: 604800, 106 clientId: clientId, 107 trafficSourceInternalReferrers: [ 108 "^(.*\\.)?thegenealogist\\.co\\.uk$", 109 "^(.*\\.)?thegenealogist\\.com$", 110 ] 111 });
112 window.adalyserTracker("trackSession", "lce1"); 113 })("genealogysupplies"); 114 }; 115 116 // ---------------------------------------- /Adalyser ---------------------------------------- 117 118 function consentUpdate( 119 consentChoiceAdvert, 120 consentChoiceAnalytic, 121 ) { 122 // Update the consent choices in the data layer 123 gtag('consent', 'update', { 124 'ad_user_data': consentChoiceAdvert, 125 'ad_personalization': consentChoiceAdvert, 126 'ad_storage': consentChoiceAdvert, 127 'analytics_storage': consentChoiceAnalytic, 128 }); 129 130 window.uetq.push('consent', 'update', { 131 'ad_storage': consentChoiceAdvert 132 }); 133 134 if (consentChoiceAnalytic) { 135 adalyserTrackerInitiate(); 136 } 137 138 console.info(`analytic:${consentChoiceAnalytic} advert:${consentChoiceAdvert}`); 139 } 140 141 $(() => { 142 const $modalCookieCustomise = $('#modal-cookie-customise'); 143 144 // If page has not had cookie consent element added yet, maintain existing behaviour 145 if ($modalCookieCustomise.length === 0) { 146 console.info('no toast'); 147 return consentUpdate('granted', 'granted'); 148 } 149 150 // Now lookup if the state has been saved as a cookie 151 const documentCookieSplit = document.cookie 152 .split("; "); 153 154 const consentChoiceAnalyticFromCookie = documentCookieSplit 155 .find((row) => row.startsWith('consentChoiceAnalytic=')) 156 ?.split("=")[1]; 157 158 const consentChoiceAdvertFromCookie = documentCookieSplit 159 .find((row) => row.startsWith('consentChoiceAdvert=')) 160 ?.split("=")[1]; 161 162 if ( 163 // Valid user choice stored in cookie 164 ['denied', 'granted'].includes(consentChoiceAnalyticFromCookie) 165 && ['denied', 'granted'].includes(consentChoiceAdvertFromCookie) 166 ) { 167 return consentUpdate(consentChoiceAnalyticFromCookie, consentChoiceAdvertFromCookie); 168 } 169 170 // If reached here need to render cookie choice UI 171 const $toast = $('[data-element="cookie-toast"]'); 172 const toast = bootstrap.Toast.getOrCreateInstance($toast); 173 toast.show(); 174 175 let consentChoiceAnalyticFromToast = 'granted'; 176 let consentChoiceAdvertFromToast = 'granted'; 177 178 // Toast hidden once choice made 179 $toast.on('hide.bs.toast', () => { 180 // Store the choices as cookies 181 document.cookie = `consentChoiceAnalytic=${consentChoiceAnalyticFromToast}; Max-Age=34560000; path=/; Secure`; 182 document.cookie = `consentChoiceAdvert=${consentChoiceAdvertFromToast}; Max-Age=34560000; path=/; Secure`; 183 184 consentUpdate(consentChoiceAnalyticFromToast, consentChoiceAdvertFromToast); 185 }); 186 187 // Initiate Modal element 188 const modal = bootstrap.Modal.getOrCreateInstance($modalCookieCustomise); 189 190 // On submit, toggle switches as required, then hide both the modal and toast. 191 $modalCookieCustomise.one('click', '[data-element=dismiss]', (event) => { 192 const $currentTarget = $(event.currentTarget); 193 194 const $checkboxConsentChoiceAnalytic = $modalCookieCustomise.find(':input[name=consent-choice-analytic]'); 195 const $checkboxConsentChoiceAdvert = $modalCookieCustomise.find(':input[name=consent-choice-advert]'); 196 197 // Brief delay to see switches move. 198 let timeOut = 250; 199 200 if ($currentTarget.val() === 'reject-all') { 201 $checkboxConsentChoiceAnalytic.prop('checked', false); 202 $checkboxConsentChoiceAdvert.prop('checked', false); 203 } else if ($currentTarget.val() === 'accept-all') { 204 $checkboxConsentChoiceAnalytic.prop('checked', true); 205 $checkboxConsentChoiceAdvert.prop('checked', true); 206 } else if ($currentTarget.val() === 'accept-selected') { 207 timeOut = 10; 208 } 209 210 consentChoiceAnalyticFromToast = $checkboxConsentChoiceAnalytic.prop('checked') ? 'granted' : 'denied'; 211 consentChoiceAdvertFromToast = $checkboxConsentChoiceAdvert.prop('checked') ? 'granted' : 'denied'; 212 213 toast.hide(); 214 215 setTimeout(() => { 216 modal.hide(); 217 }, timeOut); 218 }); 219 }); 220})(jQuery, window);
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.