使用适用于 iOS 的 Google Analytics API v3 进行会话控制? [英] Session control with Google Analytics API v3 for iOS?

查看:27
本文介绍了使用适用于 iOS 的 Google Analytics API v3 进行会话控制?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚用 API v3 替换了 GA 实现,并发现了这个有用的会话管理功能:https://developers.google.com/analytics/devguides/collection/ios/v3/sessions

I just replaced GA implementation with API v3, and found this useful session managing feature: https://developers.google.com/analytics/devguides/collection/ios/v3/sessions

自从我实施以来,每个会话都是在 00:00:00 测量的.

Since I implemented, every session is measured 00:00:00.

有人用过这个吗?或者我的客户端代码有问题.

Did anybody managed to use this? Or something is messed in my client code.

(基于时间间隔的会话计算为我的需要提供了不准确的数据)

(the time interval based session calculations gives inaccurate data for my needs)

推荐答案

我遇到了同样的问题,问题是一旦应用了开始会话值,它就会应用到所有未来的分析事件.这意味着您发送的每个事件都将启动一个新会话,因此将使您的所有会话都变为 0:00:00.

I was having the same problem and the issue was that once the start session value was applied it was applied to all future analytic events. This would mean that every event you send would start a new session and as a result would make all your sessions 0:00:00.

注意:这个解决方案是由另一个堆栈溢出提供给我的,但我现在似乎找不到它.我猜这不是谷歌分析的 iOS 实现.

对我有用的解决方案是在调用 start 后将 session 变量设置为 nil,这样就不会为所有未来的分析命中设置 start.

The solution that worked for me was to set the session variable to nil after calling start so that start is not set for all future analytic hits.

{
    // Start the session, only once.
    [tracker set:kGAISessionControl
            value:@"start"];

    // Set this after the session start has been sent. Only needs to be set once but you must    be sure that two starts are not sent in a row or you will end up with 0:00:00 sessions.
    [tracker set:kGAISessionControl
           value:nil]; 
}

...

{
    // Call when the session ends.
    [tracker set:kGAISessionControl
           value:@"end"];
}

这篇关于使用适用于 iOS 的 Google Analytics API v3 进行会话控制?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆