Skip to main content

data-culture not working on Consent Dialog

Comments

3 comments

  • Hi Michael,

    Google Tag Manager will strip the "data-" attributes from the script tag. You have to use

    CookiebotScript.setAttribute("data-culture", currentUserPageCulture);

    to implement “culture”.
    More details about multilingual support when using  Google Tag Manager (GTM) you can find here: https://support.cookiebot.com/hc/en-us/articles/360005164493-Multilingual-support-when-using-GTM

    Regards,
    Elina

    0
  • Abdel

    Hi Elina

    I've the same problem, I've followed the implementation recommended under "Multilingual Support when using GTM" 
    but data-culture is not read the right way.

    <script id="Cookiebot" src="https://consent.cookiebot.com/uc.js?cbid=XXXX" data-culture="{{current language}}" type="text/javascript"></script>
    <script>
    function CookiebotCallback_OnAccept() {
    if (Cookiebot.consent.preferences)
    dataLayer.push({'event':'cookieconsent_preferences'});
    if (Cookiebot.consent.statistics)
    dataLayer.push({'event':'cookieconsent_statistics'});
    if (Cookiebot.consent.marketing)
    dataLayer.push({'event':'cookieconsent_marketing'});
    }
    </script>

    so where do you advise implementing:

    CookiebotScript.setAttribute("data-culture", currentUserPageCulture);

    Thanks in advance for your help

    Abdel

    0
  • Hi Abdel,

    As mentioned in the above commend GTM will strip the "data-" attributes from the script tag, so you have to use a custom JavaScript variable to implement "culture". More details about multilingual support when using GTM you could find here:
    https://support.cookiebot.com/hc/en-us/articles/360005164493-Multilingual-support-when-using-GTM

    Basically, you can create a custom JavaScript variable named "Current Language" that returns a two-letter ISO language code based on custom logic and your website. So depending on your language code and the path of the URL that the user is currently visiting on your website the language would be set. 
    For example, if the user is accessing the site through the www.website.com/EN the language would be set to English.
    At the link above can find an example of the custom JavaScript function and where to add it in order to achieve your goal.

    Regards,
    Spas

    0

Please sign in to leave a comment.