Information & support > Knowledge base > Google Tag Manager >Laatst bijgewerkt opMarch 12, 2021When you operate a multilingual website and would like to have the cookie banner displayed in the same language as your website (E.g. English for “mywebsite.com/en” and Spanish for “mywebsite.com/es”) you can use the data-culture attribute.While this can be achieved in multiple ways, you may for example create a Custom JavaScript Variable named “Current Language” that returns a two-letter ISO language code based on custom logic. In this example, the language is set to either French or Spanish and will default to English, depending on the path of the URL that the user is currently visiting on your website:<script> var CookieConsentScriptContainer = document.getElementsByTagName('script')[0]; var CookieConsentScript = document.createElement("script"); CookieConsentScript.type = "text/javascript"; CookieConsentScript.id = "CookieConsent"; CookieConsentScript.src = "https://consent.cookiebot.com/uc.js?cbid=00000000-0000-0000-0000-000000000000"; var currentUserPagePathname = location.pathname.toLowerCase(); var currentUserPageCulture = "en"; //default to english if (currentUserPagePathname.indexOf("/fr")==0) { currentUserPageCulture = "fr"; } else if (currentUserPagePathname.indexOf("/es")==0) { currentUserPageCulture = "es"; } CookieConsentScript.setAttribute("data-culture", currentUserPageCulture); CookieConsentScriptContainer.parentNode.insertBefore(CookieConsentScript, CookieConsentScriptContainer); function CookieConsentCallback_OnAccept() { if (CookieConsent.consent.preferences) dataLayer.push({'event':'cookieconsent_preferences'}); if (CookieConsent.consent.statistics) dataLayer.push({'event':'cookieconsent_statistics'}); if (CookieConsent.consent.marketing) dataLayer.push({'event':'cookieconsent_marketing'}); } </script>Don’t forget to replace cbid=00000000-0000-0000-0000-000000000000 with your own code.14 day free trial CookiebotCookie scanner, cookie banner, cookie declaration and cookie consent in one solution.Use cookies on your website compliant with GDPR, ePrivacy and cookie legislationCookie management completely automatedCookie banner based on your corporate identityAutomatic composed cookie declaration, always up to dateStart 14 day free trialThe Cookiebot solution runs on 2,3 million websites, manages 7 billion monthly User Consents and supports 47+ languages.Previous Facebook Twitter LinkedIn E-mailNext
Laatst bijgewerkt opMarch 12, 2021When you operate a multilingual website and would like to have the cookie banner displayed in the same language as your website (E.g. English for “mywebsite.com/en” and Spanish for “mywebsite.com/es”) you can use the data-culture attribute.While this can be achieved in multiple ways, you may for example create a Custom JavaScript Variable named “Current Language” that returns a two-letter ISO language code based on custom logic. In this example, the language is set to either French or Spanish and will default to English, depending on the path of the URL that the user is currently visiting on your website:<script> var CookieConsentScriptContainer = document.getElementsByTagName('script')[0]; var CookieConsentScript = document.createElement("script"); CookieConsentScript.type = "text/javascript"; CookieConsentScript.id = "CookieConsent"; CookieConsentScript.src = "https://consent.cookiebot.com/uc.js?cbid=00000000-0000-0000-0000-000000000000"; var currentUserPagePathname = location.pathname.toLowerCase(); var currentUserPageCulture = "en"; //default to english if (currentUserPagePathname.indexOf("/fr")==0) { currentUserPageCulture = "fr"; } else if (currentUserPagePathname.indexOf("/es")==0) { currentUserPageCulture = "es"; } CookieConsentScript.setAttribute("data-culture", currentUserPageCulture); CookieConsentScriptContainer.parentNode.insertBefore(CookieConsentScript, CookieConsentScriptContainer); function CookieConsentCallback_OnAccept() { if (CookieConsent.consent.preferences) dataLayer.push({'event':'cookieconsent_preferences'}); if (CookieConsent.consent.statistics) dataLayer.push({'event':'cookieconsent_statistics'}); if (CookieConsent.consent.marketing) dataLayer.push({'event':'cookieconsent_marketing'}); } </script>Don’t forget to replace cbid=00000000-0000-0000-0000-000000000000 with your own code.