How to Use the Cookie Solution in a Multilingual WordPress Site

To manage multilingual sites with WordPress you can use the WPML plugin. WPML allows you to create multiple language versions of your site. Here’s how:

  1. You must first generate the iubenda code that will output the banner to the site by following the instructions in this guide.

  2. Each language has its own dedicated code snippet that must be inserted into the site’s html, as described in detail in this guide. You can enable your cookie policy on the policy edit page, on the bottom right: [Your website] > Privacy and Cookie Policy > Edit

    Activate cookie policy

    The correct code is generated when you click on “Activate cookie policy”:

    Activate cookie policy

  3. Now, simply go to the Embed page by clicking on the “Manage and Embed” link above your website name. This will take you back to the site flow/overview page of your dashboard. Click on the <>Embed button under Cookie Solution to head to the embed section. Once there, you’ll find your banner embed code.

    If you’ve generated your policies in more than one language, there will be language tabs visible for each language you’ve activated for the policy. Each tab contains the code specific to the particular language of that policy:

    Cookie Solution language tabs

    Simply click on the tab for the language you want and copy the corresponding cookie banner code.

  4. The code – which is similar to that in the example below – should be inserted before the closing of the HEAD tag:

    <script type="text/javascript">
      var _iub = _iub || []; 
      _iub.csConfiguration = {
    <script type="text/javascript" src="//" charset="UTF-8" async></script>

    As mentioned, each language has its own code, the main difference being the id it’s pointed at.

How to integrate the script of the iubenda cookie banner with WPML

4a. Use the WordPress plugin by iubenda

You can use our WordPress plugin that will detect WPML and offer forms to copy-paste the above iubenda scripts:

iubenda WPML WordPress plugin

4b. If you don’t want to use the WordPress plugin

Another way of making this work would be a full JavaScript solution as suggested by Mirco in this gist. Here’s an updated version of his approach:

<!-- replace 000001 with the site_id from your specific iubenda embed code -->
<!-- replace 000002 with the policy_id from your EN iubenda embed code -->
<!-- replace 000003 with the policy_id from your IT iubenda embed code -->

<script type="text/javascript">
var lang_id = jQuery('html').attr('lang').split('-')[0]
  , site_id = 000001; // site_id from iubenda embed code

switch( lang_id ){
  case 'en':
    var policy_id = 000002; // policy_id from iubenda embed code EN
  case 'it':
    var policy_id = 000003; // policy_id from iubenda embed code IT

  // case 'other language code' ...

var _iub = _iub || [];
_iub.csConfiguration = {
  cookiePolicyId: policy_id,
  siteId: site_id,
  lang: lang_id
<script type="text/javascript" src="//" charset="UTF-8" async></script>

Once the code has been generated by iubenda in the manner described above, it needs to be added in the HEAD section in all of the pages of the site.

See also

Still have questions?

Visit our support forum Email us