ga4 gtag.js started showing error in Chrome
Asked Answered
T

4

16

today I noticed that in Chrome gtag/js?id=... started giving an error:

Uncaught (in promise) TypeError: Failed to execute 'getValue' on 'CookieDeprecationLabel': 

in gtag.js, the error occurs here:

try {
    tc.cookieDeprecationLabel ? (a("pending"),
    (0,
    tc.cookieDeprecationLabel.getValue)().then(a)) : a("noapi") // error here
} catch (b) {
    a("error")
}

UPDATE: I hit F12 in this site (stackoverflow) and noticed that the error is present here as well (for me at least)

Tetramethyldiarsine answered 1/8 at 6:2 Comment(4)
We get the same error logged from our users suddently, comming somewhere from google tag manager / google analytics. We have no understanding of why as of now.Helwig
@DarkBee at first I thought maybe I did something wrong, after maybe my browser, now it looks like it's for everybodyTetramethyldiarsine
Well someone already filed an "issue" wit the tagmanager's support - issueThrockmorton
I thought that this is related to our code so I have upgraded all my linux packages, latest google but still there so I tried to use Firefox and this is some rescue untill this is somehow solved. So I am happy anyway that you have posted this question here cause I know what is damn happening in G00gle.Feck
M
12

This look related to third-party cookie restrictions

Like explained on Chrome facilited testing, third-party cookie restrictions will be deployed as a preview for some chrome user.

It's looks like google tag manager is using the cookieDeprecationLabel JavaScript API in order to determine if the restriction is enabled.

try {
    tc.cookieDeprecationLabel ? (a("pending"),
    (0,
    tc.cookieDeprecationLabel.getValue)().then(a)) : a("noapi")
} catch (b) {
    a("error")
}

When the cookieDeprecationLabel JavaScript API is present google tag manager try to access to it's value which throw an TypeError: Illegal invocation.

As told by @DarkBee an issue has already been opened on tagmanager's support.

If as a developer, you doesn't have the issue but want to check if your app is broken when it happen (like me) you can activate it following this google instructions Third party cookie Phase Out Facilitated Testing

[EDIT] August 12, 2024

As told by @bjarne-gerhardt-pedersen Here the issue seems to have been fixed by the GTM team.

Maraschino answered 1/8 at 10:2 Comment(0)
H
2

This seems like either GTM/GA4 or Chrome had a bad update and all the internet is having this error. Even https://developers.google.com/privacy-sandbox/relevance/setup/web/chrome-facilitated-testing#demo_and_testing

This was not happening on my website yesterday, and today it is

Handknit answered 1/8 at 16:18 Comment(0)
H
2

The problem has now been fixed in google tag manager gtm.js:

Eric Burley: We've fixed the error in gtm.js.

This means that the errors will be gone now, no matter if the setting is enabled or not chrome://flags/#tpc-phase-out-facilitated-testing

Helwig answered 9/8 at 6:35 Comment(0)
C
-5

the only temporal solution I have found is to comment out the whole GA4 code:

<!-- Google tag (gtag.js) -->
<!--
<script async src="https://www.googletagmanager.com/gtag/js?id=G-13XXXXXXXX"></script>
<script>
  window.dataLayer = window.dataLayer || [];
  function gtag(){dataLayer.push(arguments);}
  gtag('js', new Date());

  gtag('config', 'G-13XXXXXXXX');
  
</script>
-->

Hope Google will fix this soon

Cartwell answered 5/8 at 10:23 Comment(1)
While this does "remove the error" it also removes google tag manager and everything you inject via google tag manager.Helwig

© 2022 - 2024 — McMap. All rights reserved.