Skip to main content

Multilingual support when using GTM



  • Ilya Averyanov

    Hi Jacob,

    Thank you for your documentation!

    What should I write in currentUserPagePathname.indexOf(" ") if I want English to be displayed on my root domain, while German to be displayed on my de, subdomain?

    Kind regards,

  • Stephen Greis


    you don't have to write custom javascript for that. Simply do the following steps:

    • In GTM create a new variable of type "javascript variable" and name it "Current Language".
    • Set as name of the global variable: document.documentElement.lang
    • Save the GTM variable
    • Edit the Cookiebot Tag
    • As "Language" set "By GTM variable"
    • As "Language variable" set: {{Current Language}}
    • Save the Tag

    That's it...


  • Richard van der Velde

    Hi Stephen,

    Thanks for the tip. It's definitely useful, but probably not quite enough by it self.
    For example on this page, this property returns "en-US". We would have to trim off the "-US" part to make this work. Using this instead should do the trick: document.documentElement.lang.substring(0,2)

    This requires that the lang attribute is set and actually reflects the preferred language though.



  • Frida Rydén

    In the instruction:    the Cookiebot CMP Tag trigger is set as "Consent Initialisation - All Pages", and in this instruction the trigger is set as "All Pages". Which one is the correct one?

  • Richard van der Velde

    Hi Frida Rydén,

    "Consent Initialisation - All Pages" is the correct trigger to use.

    It appears the screenshot needs to be updated. Thanks for pointing this out, and I apologize for the confusion.


Please sign in to leave a comment.