5

#Facebook Instant Game FB小游戏无法使用谷歌分析gtag的解决方法

 3 years ago
source link: https://xmanyou.com/facebook-instant-game-can-not-send-event-using-gtag/
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.
neoserver,ios ssh client
21 June 2021 / facebook instant game

#Facebook Instant Game FB小游戏无法使用谷歌分析gtag的解决方法

Facebook将于2021年6月30日正式关闭Facebook分析服务,为了更好地进行数据分析,Facebook小游戏需要接入一个第三方分析服务。

在测试谷歌分析服务的时候发现,Facebook小游戏似乎无法发送数据。

这是怎么回事呢?

研究发现,这是Facebook的一个限制

https://github.com/firebase/firebase-js-sdk/issues/4046

I think I found a solution. The problem is with this year Chrome cross-site cookie handling.
Due to hosting app in an facebook iframe - cookie_flags: 'max-age=7200;secure;samesite=none' is required for request to pass thru. I'm able to override gtag initialization and push this setting after firebase initial initialization but I wonder if there is a way of passing it in firebase intial config instead of recreating gtag -
gtag('config', 'ID', { cookie_flags: 'max-age=7200;secure;samesite=none' });

在初始化gtag时,需要加入以下参数才可以

gtag('config', 'ID', { cookie_flags: 'max-age=7200;secure;samesite=none' });

这个临时解决方法带来的问题是,一旦Facebook改动了cookie的参数需求,有可能又失效了。

阿斌

Read more posts by this author.


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK