This section gives an overview about how to set a language of the Usercentrics CMP version2. In particular, this article explains the Strict and Automatic mode of setting languages and shows the way of their implementation. |
Overview
Note: In order for this walk-through to work, you need to have the relevant languages configured in your Usercentrics Admin Interface.
1. Strict Mode
Use Case
This mode is useful when operating region-/language-specific websites that should always be shown in a particular language.
Implementation
You can initialize the Usercentrics script directly using your language of choice by adding the parameter data-language="language_code"
. Please replace “language_code” with the code of the language that you would like to use1.
For customers using CMP version 2 without TCF:
<script id="usercentrics-cmp" data-language="language_code" data-settings-id="XXXXXXXX" src="https://app.usercentrics.eu/browser-ui/latest/loader.js" async></script>
For customers using TCF 2.0 (same script as above, but with additional parameter data-tcf-enabled
):
<script id="usercentrics-cmp" data-language="language_code" data-settings-id="XXXXXXXX" src="https://app.usercentrics.eu/browser-ui/latest/loader.js" data-tcf-enabled></script>
1 Please use the language code in ISO 639-1 format: List of ISO 639 language codes.
Explanation
The banner will always appear in the specified language.
2. Automatic Mode
Use Case
The automatic mode is useful when operating a single website that receives international traffic and that is available in several different languages. It allows website operators to dynamically determine which language the CMP should be shown in.
Also, this mode respects the user’s choice if the user changed the language via the language switch in the CMP UI, as the language is stored in the local storage and the CMP will be initialized with the language from the user’s local storage on recurring website visits.
Implementation
Implement your Usercentrics script without defining a language and let Usercentrics automatically determine in which language your CMP should be displayed:
For customers using CMP version 2 without TCF:
<script id="usercentrics-cmp" data-settings-id="XXXXXXXX" src="https://app.usercentrics.eu/browser-ui/latest/loader.js" async></script>
For customers using TCF 2.0 (same script as above, but with additional parameter data-tcf-enabled
):
<script id="usercentrics-cmp" data-settings-id="XXXXXXXX" src="https://app.usercentrics.eu/browser-ui/latest/loader.js" data-tcf-enabled></script>
Explanation
Usercentrics follows a certain hierarchy to determine which language value should be used to display your CMP. The hierarchy is as follows:
-
CDCS Local Storage (the user’s language preferrence is transferred from another website that is connected to the current website via Usercentrics' Cross-Domain-Consent-Sharing iFrame)
-
Website Local Storage (the user’s language preferrence is already stored in the local storage of the current website because he/she has visited the page before)
-
lang-attribute on <html> tag (e.g.
<html lang=”language_code”>
is integrated on the website) -
the user’s browser language
-
Default Visible Language as set up in the Admin-Interface if the user’s browser language is not part of the preselected language set.
The language that the CMP chooses will be written into the local storage of the website and any Usercentrics element will be displayed in that language to the user during future visits.
Summary
Usercentrics offers two main “modes” to set the language of the privacy banner. The strict mode allows the CMP to be shown only in one specific language. Therefore the language specification should be set in the CMP script. In the Automatic mode you let Usercentrics automatically determine in which language your CMP should be displayed based on certain hierarchy. This later mode is relevant for websites that receives international traffic.
Comments
0 comments
Please sign in to leave a comment.