data-culture not working on Consent Dialog
I followed the documentation to be able to force a specific language for my content, as we have language specific sites. Thedata-culture attribute is working fine on the Cookie Declaration page content, but it is not working for the Consent Dialog. It still takes the user's preferred language instead of using the one specified in the script.
My script for our italian site, for example, looks like this (I've intentionally cleared out the ID for this example):
<script id="Cookiebot" src="https://consent.cookiebot.com/uc.js?cbid=XXXX" data-culture="it" 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>
We have implemented through Google Tag Manager. Again, the consent fires OK, but it displays in the user's preferred language rather than in the one specified in the script's data-culture.
Thanks
-
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-GTMRegards,
Elina0 -
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-GTMBasically, 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,
Spas0
Please sign in to leave a comment.
Comments
3 comments