Cookiebot is able to detect the language setting of the end user's browser and adjust the language accordingly. And if you have sub domains, you can assign each to a domain group with their own (default) language.
But there are also situations where you want to determine the language the Cookiebot banner and the cookie declaration by a value in the URL, for example:
- domain.com/nl (language in the pathname)
- nl.domain.com (language as a subdomain)
- domain.nl (Country defined in the domain extension)
First off, to make a language available, the language needs to be added in the Manager.
Under Settings, navigate to the Content tab, and add the desired language(s) by clicking on the green ✚ button.
You can then use one of the following snippets to insert the Cookiebot script with one of these languages determined by a value in the URL. These scripts replace the Cookiebot scripts you would normally use.
If you are looking to add this feature to a Google Tag Manager setup, we recommend following this guide instead.
The scripts searches for language codes in the same order as they are listed above (1st: pathname, 2nd: subdomain, 3rd: extension). If no match is found, the default language is applied.
The script takes into account cases where the country code and the language codes don't match:
Country | Country code | Language code |
---|---|---|
Australia | AU | EN |
Canada | CA | EN |
Czech Republic | CZ | CS |
Denmark | DK | DA |
Estonia | EE | ET |
Norway | NO | NB * |
Sweden | SE | SV |
United Kingdom | UK | EN |
You can enter your own data to update the snippets so you can directly copy and paste them in the header of your website.
Enter your own CBID here:
You can find your CBID in the Manager, on the "Your scripts" tab.
If you need the default language to be anything other than "en" (English) enter the desired 2 character language code here:
The Cookiebot script with automatic cookie-blocking:
<script>(function(C,oo,k,ie,b,o,t){
var a=C.scripts[0],d=C.createElement(ie),e=[/^\/([a-z]{2})([_-][a-z]{2})?(\/.*)?$/g.
exec(k),/^([a-z]{2})\./.exec(oo),/\.([a-z]{2,})$/.exec(oo)],f={au:"en",ca:"en",cz:
"cs",dk:"da",ee:"et",no:"nb",se:"sv",uk:"en"},g=0;for(g of e){e=g?g[1]:t;if(g)break}
e=e.length!=2?t:e;e=f[e]?f[e]:e;d.id=b;d.setAttribute("data-blockingmode","auto");
d.src="https://consent.cookiebot.com/uc.js?cbid="+o;d.async=!1;d.setAttribute(
"data-culture",e);a.parentNode.insertBefore(d, a)})(document,location.hostname,
location.pathname,"script","Cookiebot","00000000-0000-0000-0000-000000000000","en")
</script>
The Cookiebot script without automatic cookie-blocking:
<script>(function(C,oo,k,ie,b,o,t){
var a=C.scripts[0],d=C.createElement(ie),e=[/^\/([a-z]{2})([_-][a-z]{2})?(\/.*)?$/g.
exec(k),/^([a-z]{2})\./.exec(oo),/\.([a-z]{2,})$/.exec(oo)],f={au:"en",ca:"en",cz:
"cs",dk:"da",ee:"et",no:"nb",se:"sv",uk:"en"},g=0;for(g of e){e=g?g[1]:t;if(g)break}
e=e.length!=2?t:e;e=f[e]?f[e]:e;d.id=b;d.setAttribute("data-culture",e);d.src=
"https://consent.cookiebot.com/uc.js?cbid="+o;d.async=!0;a.parentNode.insertBefore(
d, a)})(document,location.hostname,location.pathname,"script","Cookiebot",
"00000000-0000-0000-0000-000000000000","en")</script>
The CookieDeclaration script:
<script>(function(de,cl,ar,at,i,o,n){
var a=de.createElement(at),b=[/^\/([a-z]{2})([_-][a-z]{2})?(\/.*)?$/g.exec(cl),
/^([a-z]{2})\./.exec(ar),/\.([a-z]{2,})$/.exec(ar)],c={au:"en",ca:"en",cz:"cs",dk:
"da",ee:"et",no:"nb",se:"sv",uk:"en"},d=de.scripts,e=d[d.length-1],f=0;for(f of b){
b=f?f[1]:n;if(f)break}b=b.length!=2?o:b;b=c[b]?c[b]:b;a.id=i;a.async=!0;a.src=
"https://consent.cookiebot.com/"+o+"/cd.js";a.setAttribute("data-culture",b);e.
parentNode.insertBefore(a,e)})(document,location.pathname,location.hostname,
"script","CookieDeclaration","00000000-0000-0000-0000-000000000000","en")</script>
* For Norwegian you can choose add both Bokmål (NB) which is the default, or Nynorsk (NN). If you prefer using Nynorsk instead of Bokmål, you'll need to make a small change to the scripts.
Specifically, you'll need to change no:"nb"
to no:"nn"
:
Comments
0 comments
Article is closed for comments.