谷歌分析提交事件时报错:Storage not available. Aborting hit.
source link: https://xmanyou.com/ga-gtag-event-failed-storage-not-available-aborting-hit/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
谷歌分析提交事件时报错:Storage not available. Aborting hit.
相同的谷歌分析代码,在普通页面上正常运行,但是在iFrame的页面中,却发现有些事件无法正常上报。
通过谷歌分析调试工具发现了奇怪的错误:
Cookie write failed.
Storage not available. Aborting hit.
这是由于Chrome的cookie设置决定的,具体原因可以查看ga文档:
https://developers.google.com/analytics/devguides/collection/gtagjs/cookies-user-id
解决方法就是需要在初始化时手动设置一个参数:
cookie_flags: secure;samesite=none
完整初始化示例:
gtag('config', gaId, { cookie_flags: 'secure;samesite=none' });
这个问题与之前在Facebook小游戏平台上使用ga遇到的问题一样:
https://xmanyou.com/facebook-instant-game-can-not-send-event-using-gtag/
阿斌
Read more posts by this author.
扫一扫关注微信公众号:耿直的IT男阿斌
聊一聊IT男眼中的世界
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK