Skip to main content

Multilingual support when using GTM

Comments

5 comments

  • 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 mydomain.com root domain, while German to be displayed on my de,mydomain.com subdomain?

    Kind regards,
    Ilya

    0
  • Stephen Greis

    Hi,

    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...

     

    0
  • 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.

     

     

    0
  • Frida Rydén

    Hi!
    In the instruction: https://support.cookiebot.com/hc/en-us/articles/360003793854-Google-Tag-Manager-deployment    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?

    0
  • 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.

    0

Please sign in to leave a comment.