Built in Google Consent Mode V2 Duplicating the "Default" Tag

Built in Google Consent Mode V2 Duplicating the "Default" Tag

Andreaaco
Shopify Partner
8 0 3

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:

Andreaaco_0-1712045227912.png

 

 

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.

Replies 5 (5)

Mike-Consentik
Shopify Partner
191 30 37

Hi @Andreaaco 

 

This is Mike from Consentik

 

Are you using Google & Youtube channel to setup GTM/GA and set the conversion tracking on it?

If you find this helpful, please give it a like or mark it as a solution.
Consentik GDPR Cookie Banner: Effortlessly stay in compliance with EU GDPR and CCPA with Google Consent Mode V2. Free plan available and 24/7 Support
Andreaaco
Shopify Partner
8 0 3

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

Andreaaco
Shopify Partner
8 0 3

Hi @Mike-Consentik 

🙈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.

 

Mike-Consentik
Shopify Partner
191 30 37

@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

If you find this helpful, please give it a like or mark it as a solution.
Consentik GDPR Cookie Banner: Effortlessly stay in compliance with EU GDPR and CCPA with Google Consent Mode V2. Free plan available and 24/7 Support
Andreaaco
Shopify Partner
8 0 3

thanks @Mike-Consentik , I've DM you