Usercentrics - PUBLIC

How do I determine the language of the privacy banner based on the content of the website?

In this article you will learn how to initialize the Usercentrics script directly with a language.

In this article you will learn how to initialize the Usercentrics script directly with a language.

Overview


Please replace "language_code" with the actual language_code1 of your desired language:

<script type="application/javascript" src="https://app.usercentrics.eu/latest/main.js" language="language_code" id="XXXXXXXX" ></script>

1Use the ISO 639-1 language_code for this: https://en.wikipedia.org/wiki/ISO_639-1.


Set language via meta tag

If you have already included an appropriate meta tag on your website, you can also initialize the Usercentrics CMP with it. To do this, insert the following code into your web page and replace "language abbreviation" with the actual language_code1 of your desired language:

<meta http-equiv="language" content="language_code"> <script type="application/javascript" src="https://app.usercentrics.eu/latest/main.js" language="automatic" id="XXXXXXXX" ></script>

Update language via frontend API

If you notice that the user switches to a German page, you can call the following window function:

usercentrics.updateLanguage("de");

If you notice that the user switches to an English page, use the following window function:

For a French page use consequently:

If you run in race conditions (e.g. the main script is not loaded yet), you can put this wrapper around the function:



Do you need further help?

How can I get help with technical questions?

 

Usercentrics - PUBLIC