Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ga4 gtag.js started showing error in Chrome

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)

like image 721
buga Avatar asked Jan 18 '26 16:01

buga


2 Answers

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.

like image 172
GTH Avatar answered Jan 20 '26 07:01

GTH


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

like image 38
Diego Scataglini Avatar answered Jan 20 '26 05:01

Diego Scataglini



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!