A space to discuss online store customization, theme development, and Liquid templating.
Hello,
We have implemented Google's Consent Mode V2 on all of our clients sites, but three of them have the following issue:
When any page loads, the dataLayer shows the "consent", "default" twice.
The implementation is the same for all clients (except for the use of GTM), and is done as follows:
Theme.liquid and Checkout -> Additional Scripts (for the order status page)
<!-- Google Default Consent Mode --> <script> window.dataLayer = window.dataLayer || []; function gtag(){dataLayer.push(arguments);} gtag("consent", "default", { "ad_storage": "denied", "analytics_storage": "denied", "ad_user_data": "denied", "ad_personalization": "denied", "wait_for_update": 500 }); </script> <!-- Google Default Consent Mode End --> <!-- Google Tag Manager --> <script>(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start': new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0], j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src='https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f); })(window,document,'script','dataLayer','GTM-XXXXXX');</script> <!-- End Google Tag Manager --> <!-- OneTrust Cookies Consent Notice start for site.com --> <script type="text/javascript" src="https://cdn-ukwest.onetrust.com/consent/xxxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/OtAutoBlock.js" ></script> <script src="https://cdn-ukwest.onetrust.com/scripttemplates/otSDKStub.js" type="text/javascript" charset="UTF-8" data-domain-script="xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" ></script> <script type="text/javascript"> function OptanonWrapper() { } </script> <!-- OneTrust Cookies Consent Notice end for site.com -->
The cookie banner generates the "consent", "update" once the user interacts with it.
The problem is that for some sites, there are two "consent", "default" tags firing:
For some sites, the "consent", "default" is set to "granted" in both occasions, but for others, the first is set to "denied" and the second to "granted" in any case, before user interaction.
Checks that I've made:
- I'm mainly trying to see the things that the three sites have in common and that separate them from the sites with no issues, but so far I can't find anything.
- Some of the problematic sites use the "Google & Youtube" app to track events, and some don't
- Some of the problematic sites have a Google Tag Manager container installed, some don't, and the ones that have it installed don't have any Google Consent Mode tag or variable active.
- All sites (with the issue and without the issue) have the "consent", "default" set to "denied"
- If I remove the cookie banner, the problem with the two "consent", "default" persists.
- If I remove the "consent", "default" that's set to "denied", then only one fires and is set to "granted"
- I've seen the code related to this in Trekkie, but it's also present on the stores that don't have this error, therefore I would expect something else to be the cause.
Thanks for taking the time to review this, please provide advice to solve.
It seems to me that "Google & Youtube" app includes some code to already set the default content (file: "/cdn/s/trekkie.storefront.a8baf88[...].min.js") :
I am not sure how to influence these parameters, as I could not find any documentation around this.
Hi @Headz0r ,
The code set on Trekkie belongs solely to Shopify, is a file that's meant to help support integrations. A team is supposedly looking into this now, but they have confirmed (via email) that's an issue caused by their Trekkie file.
Unfortunately just uninstalling the "Google & Youtube" channel is not always enough to sort the issue as Trekkie's logic seems to get fixated on the previous setup.
My discussion with them is that if they insist in having the consent "default" and "update" in their trekkie file they have to ensure that the value provided by their marketingAllowed and analyticsProcessingAllowed functions be determined by the Merchant via the UI, as also, these functions should not be shared by "default" and "update" as these tags are meant to have different values, "default" needs to have it's values looking the same all of the time (regardless of user interaction) as it's the default the merchant has set for the site, only "update" should hold the user's choices, but this is being messed up by Trekkie.
Hi @Andreaaco,
I agree on your stance. Setting a "default" makes it impossible for any user to handle the problem by themselves. Possible solutions, that Shopify Trekkie Team would need to implement are, like you said:
a) Merchant can set "default" via UI
b) Trekkie checks if a "default" is set, if none is set Trekkie can set the "default" (also here the "default" should be really differentiated by region, since e.g. Switzerland "default" can be "granted" for all attributes, whereas EWR (Lichtenstein, Spain, etc..) countries would need a more restrictive "default" - "denied".
Option "b)" Would give the option, to follow the Google documentation on setting up consent, without directly contradicting the documentation.
Yes! @Headz0r
To be fair, implementing Consent Mode manually is super straight forward and most Cookie banners solve the "update" tag, so I really don't understand Shopify's need to implement it via Trekkie.
It could be helpful for the checkout pages, but we can add the tag to "customer events" therefore again not needed from Trekkie.
Also, the consent mode tags provided by trekkie don't even load first, so we are observing the "consent" "default" loaded after several other tags fire, and sometimes even after "consent" "update" fires, which is just annoying.
Well, rant over, hopefully there is enough pressure for their team to sort this as soon as possible.