简体   繁体   English

analytics.js传递时间戳

[英]analytics.js passing in timestamp

I am looking to implement Google Analytics using analytics.js rather than ga.js. 我希望使用analytics.js而不是ga.js实施Google Analytics( 分析) I would like to implement this into my hybrid HTML5 app which is served within an iOS shell. 我想将此实现到我的混合HTML5应用中,该应用在iOS Shell中提供。 I am aware of the iOS SDK but I am trying to maintain one code base for different platforms. 我知道iOS SDK,但是我试图为不同平台维护一个代码库。

I need to consider my app recording page impressions within a disconnected scenario, so I was going to store page impressions in localStorage and then when an internet connection is detected, then send each page impression individually to the Analytics service using the ga() function call. 我需要考虑我的应用程序在断开连接的情况下记录页面印象的情况,因此我打算将页面印象存储在localStorage中,然后在检测到互联网连接时,使用ga()函数调用将每个页面印象分别发送到Analytics服务。

In theory this works but I need to be able to send the page impression timestamp with each page rather than Analytics applying the timestamp when it hits their server. 从理论上讲,这是可行的,但我需要能够随每个页面发送页面展示时间戳,而不是Google Analytics(分析)在到达服务器时应用时间戳。

Can this be achieved? 能做到吗?

Thanks, 谢谢,

Rit 丽特

You are correct the iOs sdk lets you use something called Dispatching this allows you to send data that is up to 4 hours old. 没错,iOs sdk允许您使用一种名为Dispatching的东西,这使您可以发送长达4个小时的数据。

This works directly with the Measurement Protocol where it is called Queue Time 这直接与称为队列时间的“测量协议”一起使用

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. 该值必须大于或等于0。大于4小时的值可能会导致未处理匹配。

As far as I can see analytics.js doesn't allow you to do this, but it is just a JavaScript library that sends data to the Measurement Protocol. 据我所知,analytics.js不允许您执行此操作,它只是一个JavaScript库,用于将数据发送到Measurement Protocol。 It would probably be tricky getting that to work with Analytics.js which is probably why Google hasn't added it. 使它与Analytics.js一起使用可能会很棘手,这可能就是Google没有添加它的原因。

My advice to you is to store your data as you say locally then send it directly to Google though the Measurement Protocol. 我的建议是,按照您在本地所说的那样存储数据,然后通过Measurement Protocol将其直接发送给Google。 Just remember it has to be less then 4 hours old, you will have to hope that network returns by then. 只要记住它必须少于4个小时,您就必须希望到那时网络能够恢复。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM