/*! * CW-external — static copy of the Data API record (WEBSITES-7768, 2026-11-13). Served from disk * at /api/data/get/CW-external before PHP. No JS Content-Type: never enable nosniff for this path. * Edit = edit this file and deploy, not the BO. Docs: docs/CONSENT-AND-COOKIES.md §6.1. */ (function() { if (typeof gtag !== "function") { window.dataLayer = window.dataLayer || []; window.gtag = function() { window.dataLayer.push(arguments); }; } function getCookieSimple(name) { const searchName = `${name}=`; const cookiesDecoded = decodeURIComponent(document.cookie); const cookiesArray = cookiesDecoded.split("; "); const find = cookiesArray.find(item => item.indexOf(searchName) === 0); if (find) { return find.substring(searchName.length); } return ""; } function saveGtagDataSimple(data) { try { gtag("consent", "update", { ad_storage: data.advertising ? "granted" : "denied", analytics_storage: data.performance ? "granted" : "denied", ad_personalization: data.personalizedAdvertising ? "granted" : "denied", ad_user_data: data.useDataForAdvertising ? "granted" : "denied" }); console.log("Consent was updated from cookie"); } catch (e) { console.log("Google tag manager is not found"); } } let debug = true; let detectedUserCountry = "CH"; let langIso2 = "en"; if (typeof CCODE !== "undefined") { detectedUserCountry = CCODE; } else if (typeof userCountry !== "undefined") { detectedUserCountry = userCountry; } if (document.location.href.indexOf("force_country=FR") > -1) { detectedUserCountry = "FR"; debug = true; } detectedUserCountry = detectedUserCountry.toUpperCase(); if (typeof globalLang !== "undefined") { langIso2 = globalLang; } else if (typeof LANG_CODE !== "undefined") { langIso2 = LANG_CODE; if (langIso2 == "") { langIso2 = "en"; } } langIso2 = langIso2.toLowerCase(); if (debug) console.log("=== Lang: ", langIso2, " === Country: ", detectedUserCountry); const euCountries = [ "AT", "BE", "BG", "HR", "CY", "CZ", "DK", "EE", "FI", "FR", "DE", "GR", "HU", "IS", "IE", "IT", "LV", "LI", "LT", "LU", "MT", "NL", "NO", "PL", "PT", "RO", "SK", "SI", "ES", "SE", "GB" ]; if (euCountries.indexOf(detectedUserCountry) > -1) { const allCookies = document.cookie; const cookiesArray = allCookies.split(";"); var cookiesObject = {}; cookiesArray.forEach(function(cookie) { var parts = cookie.split("="); var name = parts[0].trim(); var value = decodeURIComponent(parts[1]); cookiesObject[name] = value; }); const cookieValRaw = cookiesObject["yummyCookieWidget_userData"]; // hide default panel if (document.querySelector("#cookiesMsg") !== null) { // dukascopy.bank document.querySelector("#cookiesMsg").remove(); } if (cookieValRaw) { const cookieVal = JSON.parse(cookieValRaw); if (debug) console.log("===Exist====", cookieVal); const savedData = getCookieSimple(cookieName); if (savedData) { const parsedSavedData = JSON.parse(savedData); console.log("--====---"); saveGtagDataSimple(parsedSavedData); } } else { gtag("consent", "default", { "ad_storage": "denied", "ad_user_data": "denied", "ad_personalization": "denied", "analytics_storage": "denied" }); const scriptElement = document.createElement("script"); if (debug) console.log("=== No chookie found ===="); scriptElement.src = `https://www.dukascopy.com/api/data/get/yummyCookieWidget?lang=${langIso2}&forJs=1&branchId=1&noCache=0&v=1.0.9`; document.body.appendChild(scriptElement); } } else { if (debug) console.log("=== Non EU country ===="); // Non EU country //================ gtag("consent", "default", { "ad_storage": "granted", "ad_user_data": "granted", "ad_personalization": "granted", "analytics_storage": "granted" }); } })();