Google Consent Mode V2 duplicated "default" tag

Andreaaco
Shopify Partner
6 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:

Screenshot 2024-03-21 at 11.03.24.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 0 (0)