- TLC Home Home
- Discussions Discussions
- Documentation Documentation
- Knowledge Base Knowledge Base
- Education Education
- Blog Blog
- Support Desk Support Desk
08-21-2020 06:39 AM - edited 08-21-2020 07:28 AM
Hello,
I am trying, for the GDPR "Explicit Consent Prompt" and "Consent Preferences Dialog" to override the user's browser's language preferences with the page HTML's lang attribute (accessible via JS:
document.documentElement.lang
and I see in the docs we should use this script to override the language preference:
window.utag_cfg_ovrd = window.utag_cfg_ovrd || {};
window.utag_cfg_ovrd.gdprDLRef = "<some data layer var e.g. meta.lang/page_lang>";
it, unfortunately, doesn't seem to work for me.
So far I have tried:
window.utag_cfg_ovrd = window.utag_cfg_ovrd || {}; window.utag_cfg_ovrd.gdprDLRef = document.documentElement.lang;
but also:
window.utag_cfg_ovrd = window.utag_cfg_ovrd || {}; window.utag_cfg_ovrd.gdprDLRef = "fr";
or:
window.utag_cfg_ovrd = window.utag_cfg_ovrd || {}; window.utag_cfg_ovrd.gdprDLRef = '<html lang="fr">';
none seem to be working for me, what am I missing?
I am thinking I am maybe adding it to the wrong place? So far I was adding it to the Explicit Consent Prompt JS.
Thanks!
Solved! Go to Solution.
08-25-2020 02:08 AM
Hi @raphaelF
So the gdprDLRef
actually refers to a data layer property name.
So in your data layer you would have:
utag_data = {
......
page_lang: document.documentElement.lang
};
Then you would set the override like so (in a preloader extension):
window.utag_cfg_ovrd = window.utag_cfg_ovrd || {};
window.utag_cfg_ovrd.gdprDLRef = "page_lang";
When the consent modals appear they will then look at utag.data[
which would then give back the language to use.utag_cfg_ovrd.gdprDLRef
]
Adrian
08-25-2020 02:40 AM
08-25-2020 03:54 AM
Hi @raphaelF
So you can go down the route of updating your page utag_data object.
However, if you can't or don't want to go down that route, I would suggest using a preloader extension to add it into the datalayer object.
So something like:
window.utag_data = window.utag_data || {};
window.utag_data.page_lang = document.documentElement.lang;
I would suggest to also add page_lang
to the data sources tab in iQ so that others now of its existence.
Adrian
08-25-2020 05:10 AM
Hey @adrian_browning,
Thanks a lot again for your answers ! Turned out my issue was I forgot to turn my extension as "Pre Load" scope.
For future reference, this is the way I fixed it:
- In IQ Tag Management > create an extension, set its scope as "Pre Load", and paste this code:
window.utag_cfg_ovrd = window.utag_cfg_ovrd || {}; window.utag_cfg_ovrd.gdprDLRef = "page_lang";
- in the script added directly to my HTML pages, I added the object property:
page_lang: document.documentElement.lang
it now works perfectly.
Thanks again !
Copyright All Rights Reserved © 2008-2023