【问题标题】:Event Duration in mobile analytics?移动分析中的事件持续时间?
【发布时间】:2011-04-15 12:25:30
【问题描述】:

我正在为我的 iphone 应用程序使用 Localytics 移动分析。例如,用户花了多少时间来查看屏幕……这可能在匆忙中是可能的……API 可用……但在 Localytics 中是可能的?

【问题讨论】:

    标签: android iphone ipad ios4 localytics


    【解决方案1】:

    使用 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";
    }
    

    【讨论】:

      猜你喜欢
      • 2016-08-08
      • 1970-01-01
      • 2021-08-31
      • 1970-01-01
      • 2021-12-11
      • 1970-01-01
      • 2019-07-21
      • 1970-01-01
      • 2012-07-10
      相关资源
      最近更新 更多