Skip to main content

How does language detection work?

CookieChimp automatically detects the language to display your consent banner in. The detection method is configured in your banner settings and uses one of the following:
  1. HTML document language — the lang attribute on the <html> element (e.g. <html lang="fr">).
  2. Browser language — the language set in the visitor’s browser preferences.
Language Detection The default language is used if the visitor’s language is not supported or there is no translation available for the visitor’s language.

How do I override the detected language?

In some cases, you may want to display the banner in a language that differs from what is automatically detected. For example, your site might serve content in a language that doesn’t match the HTML lang attribute or the visitor’s browser language. CookieChimp resolves the display language using the following priority order:
  1. window.CookieChimpLang — a global JavaScript variable you set before the CookieChimp script loads.
  2. data-lang attribute on the <html> element.
  3. The default detection method configured in your banner settings (HTML lang attribute or browser language).
The HTML lang attribute remains the recommended way to control the banner language, since it also benefits SEO and accessibility. Only use the override methods below if you need the banner language to differ from the document language.

Using window.CookieChimpLang

Add a script before the CookieChimp snippet to set the language:
<script>
  window.CookieChimpLang = "de";
</script>

Using data-lang attribute

Add a data-lang attribute to your <html> tag:
<html lang="en" data-lang="de">
In this example, the page’s document language is English, but the consent banner will be displayed in German.
The language value must be a valid ISO 639-1 language code (e.g. en, fr, de, es) and you must have a translation available for that language in your banner settings.

How do I translate the banner?

Consent banners can be translated into multiple languages. We offer AI auto translate for paid accounts to quickly translate into another language.
Always check and verify AI translations before saving.
Banner Translation Similarly categories, services and storage items can be individually translated. Category Translation Service Translation Cookie Translation