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

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

问题描述

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



自从我实施,每个会话的时间都是00:00:00。



有没有人设法使用它?
客户端代码。



(基于时间间隔的会话计算为我的需要提供了不准确的数据) $ b $我遇到了同样的问题,问题是一旦应用了开始会话值,它就会应用到所有未来的分析事件中。这意味着你发送的每一个事件都会开始一个新的会话,因此会让你的所有会话都成为0:00:00。注意:这个解决方案是由另一个堆栈溢出给我的,但现在我似乎无法找到它。我猜这不是iOS分析的谷歌分析。



这个解决方案对我来说很有用,就是在调用start之后将session变量设置为零因此不会为所有未来的分析命中设置开始。

  {
//只开始一次会话。
[tracker set:kGAISessionControl
value:@start];

//在会话开始发送后设置。只需要设置一次,但您必须确保两次启动不会连续发送,否则您将以0:00:00会话结束。
[tracker set:kGAISessionControl
value:nil];
}

...

{
//会话结束时调用。
[tracker set:kGAISessionControl
value:@end];
}


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

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)

解决方案

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.

Note: This solution was given to my by another stack overflow but I can't seem to find it now. I am guessing it wasn't an iOS implementation of google analytics.

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"];
}

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

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