How to Override the Consent Language

This guide is applicable only for websites that have the Dynamic Localization option enabled in Clickio Consent settings.

By default, the language is selected based on the user’s browser data.

When integrating Clickio Consent, you might need to override the dialog language dynamically, using the lang= parameter. This can be useful when your website supports multiple languages and serves users based on different domains.

Code example:

<script type="text/javascript">
	var lang = "en"; // Programmatically set the desired language here

	// Append the Clickio Consent script 
    var script = document.createElement("script");
    script.async = true;
    script.type = "text/javascript";
    script.src = "//clickiocmp.com/t/consent_111111.js?lang=" + lang;
    document.head.appendChild(script); 
</script>

You should place the code inside the <head> HTML-tag

How to use:
  • The lang variable should be set to the desired language (client-side or server-side). The value must be two-letter ISO 639 code.

  • The specified language must be enabled in the Dynamic Localization settings; otherwise, it will be ignored.

  • Replace 111111 in the following line with your Clickio Site ID: script.src = "//clickiocmp.com/t/consent_111111.js?lang=" + lang; 

Automatic Language Detection by Domain

If your website operates on multiple domains for different languages, you can use the following script to automatically determine the correct language:

<script type="text/javascript">
  (function() {
      var domainLangMap = {
          "www.yoursite.com": "en", // English version
          "es.yoursite.com": "es", // Spanish version
          "fr.yoursite.com": "fr"  // French version
      };

      var currentDomain = window.location.hostname; // Get the current domain
      var lang = domainLangMap[currentDomain] || "en"; // Default to English if not found

	  // Append the Clickio Consent script
      var script = document.createElement("script");
      script.async = true;
      script.type = "text/javascript";
      script.src = "//clickiocmp.com/t/consent_111111.js?lang=" + lang; // Inject the correct language parameter
      document.head.appendChild(script); 
  })();
</script>

You should place the code inside the <head> HTML-tag

How to use:
  • Map your language subdomains in the domainLangMap 
  • The language names must be mapped using the two-letter ISO 639 code.

  • The specified languages must be enabled in the Dynamic Localization settings; otherwise, they will be ignored.

  • Set the default fallback-language in the line: var lang = domainLangMap[currentDomain] || "en";
  • Replace 111111 in the following line with your Clickio Site ID: script.src = "//clickiocmp.com/t/consent_111111.js?lang=" + lang;