/* Cookie consent banner with Google Consent Mode v2. * * The Google tag is published in
by layout.html, with consent defaults * (everything denied) declared immediately before it. Google's install snippet * and Search Console's tag check both expect the tag to be present in the * document, and with storage denied it writes no cookie and builds no profile — * it sends cookieless pings until the visitor decides. * * This script owns the decision: * · shows the banner once and stores the answer for a year, * · on accept, calls gtag('consent','update', granted) so the tag that is * already loaded starts using cookies, then injects the non-Google pixels, * · on reject — and on every later page — confirms denied, so a refusal is * durable rather than a one-off. * No non-Google pixel is fetched before an accept. */ (function () { var KEY = "db_consent_v1"; var script = document.currentScript; // The Google ids (data-ga / data-gtm / data-ads) are no longer read here: // the tag is published in , so this script only has to flip consent. // Non-Google pixels. Same rule as the Google ones: nothing is fetched until // the visitor accepts, and each id is optional so the panel can carry any // subset. A plain list keeps adding a provider to one entry here plus one data // attribute in the layout. var extraPixels = []; if (script) { [ ["data-meta-pixel", "meta"], ["data-tiktok-pixel", "tiktok"], ["data-pinterest-tag", "pinterest"], ["data-clarity", "clarity"], ["data-hotjar", "hotjar"], ["data-linkedin", "linkedin"], ["data-snap-pixel", "snap"], ["data-twitter-pixel", "twitter"] ].forEach(function (pair) { var v = script.getAttribute(pair[0]); if (v) extraPixels.push({ provider: pair[1], id: v }); }); } function read() { try { return JSON.parse(localStorage.getItem(KEY) || "null"); } catch (e) { return null; } } function save(value) { try { localStorage.setItem(KEY, JSON.stringify({ analytics: value, at: Date.now() })); } catch (e) {} } function pushConsent(value) { if (typeof window.gtag !== "function") return; window.gtag("consent", "update", { ad_storage: value ? "granted" : "denied", ad_user_data: value ? "granted" : "denied", ad_personalization: value ? "granted" : "denied", analytics_storage: value ? "granted" : "denied" }); } /* The Google tag itself is no longer injected here. * * It is published in on every page (layout.html) with Consent Mode v2 * defaults declared first, because that is where Google's install snippet and * Search Console's tag check expect it. Publishing it early is safe: with * every storage type denied the tag sends cookieless pings and writes no * cookie, and it honours the update this script sends below. Injecting a * second copy from here would double every page view. * * What remains is pushConsent(): moving the already-loaded tag from denied to * granted when the visitor accepts, and confirming denied when they refuse, so * a refusal survives reloads instead of resetting to "undecided". */ /* loadPixels injects the non-Google tags, called from the same place as pushConsent so consent covers every provider in one decision. Each provider is skipped when a script with its marker is already on the page: the banner can be re-rendered and the consent handler runs again on a stored choice, and a second copy of a pixel double-counts every page view. */ function loadPixels() { extraPixels.forEach(function (p) { var marker = "data-pixel-" + p.provider; if (document.querySelector("script[" + marker + "]")) return; function add(src, attrs) { var s = document.createElement("script"); s.async = true; s.src = src; s.setAttribute(marker, "1"); Object.keys(attrs || {}).forEach(function (k) { s.setAttribute(k, attrs[k]); }); document.head.appendChild(s); } switch (p.provider) { case "meta": // The standard Meta Pixel bootstrap: the inline queue must exist // before fbevents.js loads, or the first events are dropped. window.fbq = window.fbq || function () { window.fbq.callMethod ? window.fbq.callMethod.apply(window.fbq, arguments) : window.fbq.queue.push(arguments); }; window.fbq.queue = window.fbq.queue || []; window.fbq("init", p.id); window.fbq("track", "PageView"); add("https://connect.facebook.net/en_US/fbevents.js"); break; case "tiktok": window.TiktokAnalyticsObject = "ttq"; var ttq = window.ttq = window.ttq || []; ttq.methods = ["page", "track", "identify", "instances", "debug", "on", "off", "once", "ready", "alias", "group", "enableCookie", "disableCookie"]; ttq.setAndDefer = function (t, e) { t[e] = function () { t.push([e].concat(Array.prototype.slice.call(arguments, 0))); }; }; ttq.methods.forEach(function (m) { ttq.setAndDefer(ttq, m); }); ttq.load = function (id) { add("https://analytics.tiktok.com/i18n/pixel/events.js?sdkid=" + encodeURIComponent(id) + "&lib=ttq"); }; ttq.load(p.id); ttq.page(); break; case "pinterest": window.pintrk = window.pintrk || function () { window.pintrk.queue.push(Array.prototype.slice.call(arguments)); }; window.pintrk.queue = window.pintrk.queue || []; window.pintrk("load", p.id, { em: "" }); window.pintrk("page"); add("https://s.pinimg.com/ct/core.js"); break; case "clarity": (function (c, l, a, r, i, t, y) { c[a] = c[a] || function () { (c[a].q = c[a].q || []).push(arguments); }; add("https://www.clarity.ms/tag/" + encodeURIComponent(i)); })(window, document, "clarity", "script", p.id); break; case "hotjar": (function (h, o, t, j, a, r) { h.hj = h.hj || function () { (h.hj.q = h.hj.q || []).push(arguments); }; h._hjSettings = { hjid: p.id, hjsv: 6 }; add("https://static.hotjar.com/c/hotjar-" + encodeURIComponent(p.id) + ".js?sv=6"); })(window, document); break; case "linkedin": window._linkedin_partner_id = p.id; window._linkedin_data_partner_ids = window._linkedin_data_partner_ids || []; window._linkedin_data_partner_ids.push(p.id); add("https://snap.licdn.com/li.lms-analytics/insight.min.js"); break; case "snap": (function (e, n, t) { if (e.snaptr) return; var a = e.snaptr = function () { a.handleRequest ? a.handleRequest.apply(a, arguments) : a.queue.push(arguments); }; a.queue = []; add("https://sc-static.net/scevent.min.js"); e.snaptr("init", p.id); e.snaptr("track", "PAGE_VIEW"); })(window); break; case "twitter": window.twq = window.twq || function () { window.twq.exe ? window.twq.exe.apply(window.twq, arguments) : window.twq.queue.push(arguments); }; window.twq.queue = []; window.twq("config", p.id); add("https://static.ads-twitter.com/uwt.js"); break; } }); } function banner(html) { var wrap = document.createElement("div"); // The consent banner must never cover the checkout form: the buyer is one // step from paying and a 3-line overlay can hide the pay button on a phone. if (document.querySelector(".co-page")) return; wrap.className = "cookie-banner"; wrap.setAttribute("role", "dialog"); wrap.setAttribute("aria-live", "polite"); wrap.innerHTML = html; // A dialog needs an accessible name or a screen reader announces only that a // dialog opened, never what it is. Lighthouse flags exactly this. The banner // has no visible heading, so the label describes it directly, in the visitor's // language where one is known. wrap.setAttribute("aria-label", bannerLabel()); document.body.appendChild(wrap); return wrap; } // bannerLabel names the consent dialog in the current language. // // It reads the document's own lang attribute rather than the `lang` variable // declared further down: banner() runs before that declaration is reached, and // relying on hoisting for a `var` would give undefined. function bannerLabel() { try { var code = (document.documentElement.lang || "tr").slice(0, 2); var set = labels[code] || labels.en; if (set && set.more) return set.more; } catch (e) { /* fall through */ } return "Cookies"; } // Every served language, so the banner speaks the visitor's language. A // missing entry falls back to English rather than to Turkish: showing Turkish // consent text to an Arabic visitor is a compliance problem, not a cosmetic one. var labels = { tr: { text: "Deneyiminizi iyileştirmek için analiz çerezleri kullanıyoruz. Yalnızca onay verirseniz etkinleşir.", accept: "Kabul et", reject: "Reddet", more: "Çerez Politikası" }, en: { text: "We use analytics cookies to improve your experience. They only run if you accept.", accept: "Accept", reject: "Decline", more: "Cookie Policy" }, de: { text: "Wir verwenden Analyse-Cookies, um Ihr Erlebnis zu verbessern. Sie laufen nur mit Ihrer Zustimmung.", accept: "Akzeptieren", reject: "Ablehnen", more: "Cookie-Richtlinie" }, fr: { text: "Nous utilisons des cookies analytiques pour améliorer votre expérience. Ils ne s'activent qu'avec votre accord.", accept: "Accepter", reject: "Refuser", more: "Politique cookies" }, es: { text: "Usamos cookies analíticas para mejorar su experiencia. Solo se activan si las acepta.", accept: "Aceptar", reject: "Rechazar", more: "Política de cookies" }, it: { text: "Usiamo cookie analitici per migliorare la tua esperienza. Si attivano solo con il tuo consenso.", accept: "Accetta", reject: "Rifiuta", more: "Cookie policy" }, nl: { text: "We gebruiken analytische cookies om uw ervaring te verbeteren. Ze werken alleen met uw toestemming.", accept: "Accepteren", reject: "Weigeren", more: "Cookiebeleid" }, pt: { text: "Utilizamos cookies analíticos para melhorar a sua experiência. Só são ativados com o seu consentimento.", accept: "Aceitar", reject: "Recusar", more: "Política de cookies" }, ru: { text: "Мы используем аналитические файлы cookie, чтобы улучшить ваш опыт. Они работают только с вашего согласия.", accept: "Принять", reject: "Отклонить", more: "Политика cookie" }, pl: { text: "Używamy plików cookie analitycznych, aby ulepszyć Twoje doświadczenia. Działają tylko za Twoją zgodą.", accept: "Akceptuj", reject: "Odrzuć", more: "Polityka cookies" }, ro: { text: "Folosim cookie-uri analitice pentru a vă îmbunătăți experiența. Acestea rulează doar cu consimțământul dvs.", accept: "Accept", reject: "Refuz", more: "Politica cookie" }, sv: { text: "Vi använder analyscookies för att förbättra din upplevelse. De körs bara om du godkänner.", accept: "Acceptera", reject: "Avböj", more: "Cookiepolicy" }, da: { text: "Vi bruger analysecookies til at forbedre din oplevelse. De kører kun, hvis du accepterer.", accept: "Accepter", reject: "Afvis", more: "Cookiepolitik" }, no: { text: "Vi bruker analysekapsler for å forbedre opplevelsen din. De kjører bare hvis du godtar.", accept: "Godta", reject: "Avslå", more: "Cookiepolicy" }, cs: { text: "Používáme analytické cookies pro zlepšení vašeho zážitku. Spouštějí se pouze s vaším souhlasem.", accept: "Přijmout", reject: "Odmítnout", more: "Zásady cookies" }, sk: { text: "Používame analytické cookies na zlepšenie vášho zážitku. Spúšťajú sa iba s vaším súhlasom.", accept: "Prijať", reject: "Odmietnuť", more: "Zásady cookies" }, sl: { text: "Uporabljamo analitične piškotke za izboljšanje vaše izkušnje. Delujejo le z vašim soglasjem.", accept: "Sprejmi", reject: "Zavrni", more: "Politika piškotkov" }, hr: { text: "Koristimo analitičke kolačiće za poboljšanje vašeg iskustva. Rade samo uz vašu privolu.", accept: "Prihvati", reject: "Odbij", more: "Politika kolačića" }, el: { text: "Χρησιμοποιούμε cookies ανάλυσης για να βελτιώσουμε την εμπειρία σας. Ενεργοποιούνται μόνο με τη συγκατάθεσή σας.", accept: "Αποδοχή", reject: "Απόρριψη", more: "Πολιτική cookies" }, he: { text: "אנו משתמשים בקובצי Cookie לניתוח כדי לשפר את החוויה שלך. הם פועלים רק בהסכמתך.", accept: "אישור", reject: "דחייה", more: "מדיניות קובצי Cookie" }, ar: { text: "نستخدم ملفات تعريف الارتباط التحليلية لتحسين تجربتك. تعمل فقط بموافقتك.", accept: "قبول", reject: "رفض", more: "سياسة ملفات الارتباط" }, ka: { text: "ჩვენ ვიყენებთ ანალიტიკურ ქუქიებს გამოცდილების გასაუმჯობესებლად. ისინი მუშაობს მხოლოდ თქვენი თანხმობით.", accept: "მიღება", reject: "უარყოფა", more: "ქუქიების პოლიტიკა" }, ga: { text: "Úsáidimid fianáin anailíse chun do thaithí a fheabhsú. Ní ritheann siad ach amháin má ghlacann tú leo.", accept: "Glac", reject: "Diúltaigh", more: "Polasaí Fianán" } }; var lang = (document.documentElement.lang || "tr").slice(0, 2); var copy = labels[lang] || labels.en; // The banner collects consent, so it has to link to the policy that explains // what is being consented to. The default language is unprefixed; every other // language carries its prefix, exactly like every other storefront link. var defaultLang = document.documentElement.getAttribute("data-default-lang") || "tr"; var policyHref = (lang === defaultLang ? "" : "/" + lang) + "/cerez-politikasi/"; if (lang === defaultLang && defaultLang !== "tr") { // A non-Turkish default still serves the page at its prefixed URL, because // the slug itself is Turkish. policyHref = "/cerez-politikasi/"; } function show() { var el = banner( '' + '" ); // The checkout suppresses the banner on purpose (it must not cover the pay // button), and banner() therefore returns nothing there. Bail out before // binding, otherwise every checkout page threw a TypeError that stopped the // rest of this script — including the consent replay for returning visitors. if (!el) return; el.querySelectorAll("[data-consent]").forEach(function (btn) { btn.addEventListener("click", function () { var accepted = btn.getAttribute("data-consent") === "yes"; save(accepted); pushConsent(accepted); if (accepted) { loadPixels(); } el.remove(); }); }); } var stored = read(); if (stored === null) { show(); return; } // Returning visitor: re-apply the stored decision on every page. pushConsent(!!stored.analytics); if (stored.analytics) { loadPixels(); } })();