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

标签 android iphone ipad ios4 localytics

我正在为我的 iphone 应用程序使用 Localytics 移动分析。例如,用户花费了多少时间来查看屏幕...在 flurry 中是可能的。.api 可用...但在 Localytics 中是可能的吗?

最佳答案

使用 Localytics 执行此操作的最佳方法是在屏幕关闭时触发事件,将时间记录为存储桶事件属性。这样,您将获得一个漂亮的饼图,显示屏幕被查看的频率,以及查看有多少用户查看过屏幕、最常使用屏幕的设备以及 Localytics 让您查看的所有其他指标的能力您的 Activity 。

要触发此事件,您需要执行以下操作:

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

关于android - 移动分析中的事件持续时间?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5676685/

相关文章:

java - 没有 context.openFileOutput 的 FileOutputStream(file,append) 的 Context.MODE_WORLD_READABLE 权限

android - 使用列表保存 RecyclerView 状态

iphone - 如何定义一个可以在我的应用程序的任何地方访问的全局变量?

iphone - 我应该开始使用核心数据吗?

iOS - iPad 的 viewWillTransition 中错误的 UIScreen 边界

ios - 将 View Controller 从根推送到详细 View Controller (SplitView)

android - 通过 beaglebone black 中的 GPIO 映射内存

java - 如何在 Mobile OpenERP (android) 中制作自定义模块?

iphone - 如何从 animationDidStop 中删除 CALayer 对象?

iphone - 如何像 UIScrollView 一样取消触摸?