移动分析中的事件持续时间?

| 我正在为我的iPhone应用程序使用Localytics移动分析。例如,用户花了多少时间查看屏幕...在flurry..api中是可能的可用。但是在Localytics中是可能的?     
已邀请:
使用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];
这依赖于桶化功能:
- (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\";
}
    

要回复问题请先登录注册