我正在为我的iphone应用程序使用Localytics移动分析。例如,用户花了多少时间来看屏幕......有可能在乱舞......可以使用......但是Localytics可以吗?
答案 0 :(得分:4)
使用Localytics执行此操作的最佳方法是在屏幕关闭时触发事件,将时间记录为分段事件属性。通过这种方式,您将获得一个漂亮的饼图,显示屏幕的查看频率,以及查看用户查看屏幕的数量,最常用的设备以及Localytics允许您查看的所有其他指标你的活动。
要触发此事件,您需要执行以下操作:
// When you show the screen
NSDate *date = [NSDate date]; // save this somewhere
// When you close the screen:
// Find elapsed time and convert to milliseconds
// Use (-) modifier to conversion since receiver is earlier than now
unsigned int seconds = (unsigned int)([date timeIntervalSinceNow] * -1.0);
NSDictionary *dictionary =
[NSDictionary dictionaryWithObjectsAndKeys:
[self bucketizeSeconds:seconds],
@"View Time",
nil];
[[LocalyticsSession sharedLocalyticsSession]
tagEvent:@"Intro Screen viewed"
attributes:dictionary];
这取决于bucketizing功能:
- (NSString *) bucketizeSeconds:(unsigned int)seconds
{
unsigned int secondBuckets[9] = {3, 10, 30, 60, 180, 600, 1800, 3600, -1};
NSArray *secondBucketNames = [NSArray arrayWithObjects:
@"0 - 3 seconds",
@"3 - 10 seconds", @"10 - 30 seconds", @"30 - 60 seconds",
@"1 - 3 minutes", @"3 - 10 minutes", @"10 - 30 minutes", @"30 - 60 minutes",
@"> 1 hour", nil];
for(unsigned int i=0; i < (sizeof secondBuckets) / (sizeof secondBuckets[0]); i++)
{
if(secondBuckets[i] > seconds)
{
return [secondBucketNames objectAtIndex: i];
}
}
return @"error";
}