javascript - analytics.js 传递时间戳

标签 javascript google-analytics google-analytics-api measurement-protocol

我希望使用 analytics.js 实现 Google Analytics而不是 ga.js。我想将其实现到我的混合 HTML5 应用程序中,该应用程序在 iOS 外壳中提供服务。我知道 iOS SDK,但我试图为不同的平台维护一个代码库。

我需要考虑我的应用程序在断开连接的情况下记录页面展示次数,因此我打算将页面展示次数存储在 localStorage 中,然后在检测到互联网连接时,使用 ga( ) 函数调用。

理论上这是可行的,但我需要能够随每个页面发送页面印象时间戳,而不是 Analytics 在到达服务器时应用时间戳。

这能实现吗?

谢谢,

对吧

最佳答案

你是对的,iOs sdk 允许你使用一个叫做 Dispatching 的东西。这允许您发送长达 4 小时的数据。

这直接与称为 Queue Time 的测量协议(protocol)一起工作

Used to collect offline / latent hits. The value represents the time delta (in milliseconds) between when the hit being reported occurred and the time the hit was sent. The value must be greater than or equal to 0. Values greater than four hours may lead to hits not being processed.

据我所知,analytics.js 不允许您这样做,但它只是一个将数据发送到 Measurement Protocol 的 JavaScript 库。让它与 Analytics.js 一起使用可能会很棘手,这可能是 Google 没有添加它的原因。

我对您的建议是按照您所说的在本地存储您的数据,然后通过 Measurement Protocol 将其直接发送给 Google。请记住,它必须少于 4 小时,您将不得不希望到那时网络恢复。

关于javascript - analytics.js 传递时间戳,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27291002/

相关文章:

google-analytics - 清理 "dirty"Google Analytics 自定义变量键?

asp.net-mvc - MVC View News 计数器和 Google Analytics 之间的巨大差异

c# - Google Analytics(分析)仅使用C#显示直到前一天的数据

javascript - Jquery 图像预览并仍然保留在提交时?

javascript - 为什么这在 JavaScript 中返回 -1

javascript - 语法错误 : Cannot use import statement outside a module Firebase Functions

redirect - Google认为我的首页是斜线

javascript - 通过用户 ID 跟踪用户登录

r - 如何使用 Google Analytics (rga) 编写动态报告

javascript - NodeJS 和 Express 连接外部 API - 有什么有用的工具来管理收到的数据?