1/* HomeZero consent-gated analytics loader. 2 Loads GTM only after "statistics" consent and Intercom after "marketing" consent. 3 Source of truth: localStorage key hz_cookie_consent_v1 (mirrored to cookies). */ 4(function () { 5 var GTM_ID = "GTM-KPZMWKJV"; 6 var INTERCOM_APP_ID = "i7l3yn71"; 7 var loaded = { gtm: false, intercom: false }; 8 9 function readPrefs() { 10 try { 11 var raw = localStorage.getItem("cookieConsent"); 12 if (raw) { 13 var p = JSON.parse(raw); 14 return { statistics: !!p.analytics, marketing: !!p.marketing }; 15 } 16 var legacy = localStorage.getItem("hz_cookie_consent_v1"); 17 if (legacy) { 18 var lp = JSON.parse(legacy); 19 return { statistics: !!lp.statistics, marketing: !!lp.marketing }; 20 } 21 } catch (e) { /* noop */ } 22 var c = document.cookie || ""; 23 if (/(?:^|;\s*)cookies_noodzakelijke=true/.test(c)) { 24 return { 25 statistics: /(?:^|;\s*)cookies_statistieken=true/.test(c), 26 marketing: /(?:^|;\s*)cookies_marketing=true/.test(c) 27 }; 28 } 29 return null; 30 } 31 32 function loadGTM() { 33 if (loaded.gtm) return; 34 loaded.gtm = true; 35 window.dataLayer = window.dataLayer || []; 36 window.dataLayer.push({ "gtm.start": new Date().getTime(), event: "gtm.js" }); 37 var s = document.createElement("script"); 38 s.async = true; 39 s.src = "https://www.googletagmanager.com/gtm.js?id=" + GTM_ID; 40 document.head.appendChild(s); 41 } 42 43 function loadIntercom() { 44 if (loaded.intercom) return; 45 loaded.intercom = true; 46 window.intercomSettings = { api_base: "https://api-iam.intercom.io", app_id: INTERCOM_APP_ID }; 47 var w = window; 48 var ic = w.Intercom; 49 if (typeof ic === "function") { 50 ic("reattach_activator"); 51 ic("update", w.intercomSettings); 52 } else { 53 var d = document; 54 var i = function () { i.c(arguments); }; 55 i.q = []; i.c = function (args) { i.q.push(args); }; 56 w.Intercom = i; 57 var s = d.createElement("script"); 58 s.type = "text/javascript"; s.async = true; 59 s.src = "https://widget.intercom.io/widget/" + INTERCOM_APP_ID; 60 var x = d.getElementsByTagName("script")[0]; 61 x.parentNode.insertBefore(s, x); 62 } 63 } 64 65 function apply(prefs) { 66 if (!prefs) return; 67 if (prefs.statistics) loadGTM(); 68 if (prefs.marketing) loadIntercom(); 69 } 70 71 apply(readPrefs()); 72 window.addEventListener("hz:consent", function (e) { 73 apply((e && e.detail) || readPrefs()); 74 }); 75 // Also re-check when storage changes in another tab. 76 window.addEventListener("storage", function (e) { 77 if (e.key === "cookieConsent" || e.key === "hz_cookie_consent_v1") apply(readPrefs()); 78 }); 79})();
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.