Discuss and resolve questions on Liquid, JavaScript, themes, sales channels, and site speed enhancements.
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.
Hi @Andreaaco
This is Mike from Consentik
Are you using Google & Youtube channel to setup GTM/GA and set the conversion tracking on it?
Hi Mike,
I can't find any reference to "Consentik" on any of the sites with this issue,
As for the Google & Youtube channel, no, we don't use it for GTM nor GA
🙈Sorry, just saw the "from" on the first line.
But yeah, to answer the question, we don't use the channel for tracking, and this is an issue we are having on some sites (not all sites luckily) all of the ones with the issue have slightly different configurations. Actually one of the sites that do use the "Google & Youtube channel" for tracking does not have this problem.
@Andreaaco could you share your store URL then I can check for you? If you do not want to public, you can send it to me via DM
Starting a B2B store is a big undertaking that requires careful planning and execution. W...
By JasonH Sep 23, 2024By investing 30 minutes of your time, you can unlock the potential for increased sales,...
By Jacqui Sep 11, 2024We appreciate the diverse ways you participate in and engage with the Shopify Communi...
By JasonH Sep 9, 2024