在启用脱机的Web应用程序中处理Google分析(Handling Google analytics in an offline enabled web app)

我是Codiva的开发人员- java ide和在线编译器 。 我正致力于改善离线支持,减少网络使用,尽可能通过预缓存降低延迟。

我想知道如何处理对Google Analytics的请求。

首先是ga脚本。 我使用谷歌标签管理器来设置GA。 是否可以缓存该请求,也就是说,我可以对此请求使用networkFirst策略吗? 或者它应该始终是网络?

如何确保离线发生的操作得到正确跟踪?

我打算开始使用Firebase进行一些功能,firebase也有一些分析。 当设备脱机时它会自动处理分析吗?

I am a developer of Codiva - java ide and online compiler. I am working on improving offline support, reducing network usage, reducing the latency by pre-caching as much as possible.

I want to know how to handle requests to google analytics.

First is the ga script. I use google tag manager to setup GA. Is it okay to cache that request, that is, can I use networkFirst strategy for this request? Or should it always be networkOnly?

How to make sure the actions that happened offline gets tracked correctly?

I am planning to start using Firebase for some featuers, firebase also has some kind of analytics. Would it automatically handle analytics when the device goes offline?

最满意答案

首先是ga脚本。 我使用谷歌标签管理器来设置GA。 是否可以缓存该请求,也就是说,我可以对此请求使用networkFirst策略吗? 或者它应该始终是网络?

我不确定缓存GTM脚本是否明智。 analytics.js脚本相对静态,但任何有权访问GTM帐户的人都可以更新GTM脚本。 显然,在那里所做的更改不会传播给脚本的缓存版本的用户。

如何确保离线发生的操作得到正确跟踪?

关键是使用qt参数,它允许您在事后发送命中,并指定其时间偏移。

今天有一个非官方的服务工作者脚本,你应该看看。 它可能很快就会正式获得支持: https : //gist.github.com/jeffposnick/466ef7578c4c880a78c7270e6ac69620

我打算开始使用Firebase进行一些功能,firebase也有一些分析。 当设备脱机时它会自动处理分析吗?

此时,Firebase分析工具仅限移动设备。 如果您正在使用他们的Web SDK,我认为此时您不会获得任何分析。

First is the ga script. I use google tag manager to setup GA. Is it okay to cache that request, that is, can I use networkFirst strategy for this request? Or should it always be networkOnly?

I'm not sure it's wise to cache the GTM script. The analytics.js script is relatively static, but the GTM script can be updated by anyone who has access to your GTM account. Changes made in there obviously wouldn't get propagated to users of the cached version of the script.

How to make sure the actions that happened offline gets tracked correctly?

The key is to use the qt parameter, which allows you to send a hit after the fact, and specify its time offset.

There's an unofficial service worker script that does this today that you should take a look at. It will probably become officially supported sometime soon: https://gist.github.com/jeffposnick/466ef7578c4c880a78c7270e6ac69620

I am planning to start using Firebase for some featuers, firebase also has some kind of analytics. Would it automatically handle analytics when the device goes offline?

At this point Firebase analytics is mobile-only. If you're using their web SDK, I don't think you get any analytics at this point.

更多推荐