ga4 gtag.js 开始在 Chrome 中显示错误

问题描述 投票:0回答:1

今天我注意到在 Chrome

gtag/js?id=...
中开始出现错误:

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

在gtag.js中,错误发生在这里:

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

更新: 我在这个网站(stackoverflow)中按了 F12,并注意到这里也存在错误(至少对我来说)

google-chrome google-analytics-4 gtag.js
1个回答
0
投票

此外观与第三方 cookie 限制

有关

就像在 Chrome 促进测试中所解释的那样,第三方 cookie 限制将作为某些 Chrome 用户的预览部署。

看起来谷歌标签管理器正在使用 cookieDeprecationLabel JavaScript API 来确定是否启用了限制。

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

当 cookieDeprecationLabel JavaScript API 存在时,谷歌标签管理器会尝试访问它的值,这会抛出

TypeError: Illegal invocation

正如@DarkBee 所说,标签管理器的支持已经提出了一个问题。

如果作为开发人员,您没有遇到问题,但想要检查您的应用程序在发生问题时是否损坏(像我一样),您可以按照此谷歌说明激活它第三方 cookie 逐步淘汰促进测试

© www.soinside.com 2019 - 2024. All rights reserved.