Google Consent Mode V2 duplicated "default" tag

Shopify Partner
6 0 3



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 -->
  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
<!-- Google Default Consent Mode End -->

<!-- Google Tag Manager -->
new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],
<!-- End Google Tag Manager -->

<!-- OneTrust Cookies Consent Notice start for -->
<script type="text/javascript" src="" ></script>
<script src=""  type="text/javascript" charset="UTF-8" data-domain-script="xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" ></script>
<script type="text/javascript">
function OptanonWrapper() { }
<!-- OneTrust Cookies Consent Notice end for -->  

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)