簡體   English   中英

iOS Google Analytics(分析)未跟蹤應用速度

[英]iOS Google analytics not tracking App speed

我正在嘗試使用Google Analytics(分析)跟蹤我的應用速度,但在網站上看不到任何低於應用速度的信息。 但是我可以看到其他參數,例如事件,崩潰和異常。以下是我用來發送事件計時的代碼。

  self.endDate=[NSDate date];
  double timeDiff=[_startDate timeIntervalSinceDate:_endDate];
  NSLog(@"timeDiff----%f",timeDiff);
  if([[[GAI sharedInstance]defaultTracker] sendTimingWithCategory:category withValue:timeDiff withName:@"LoadTime" withLabel:category])
  {
    NSLog(@"Succesfully sent load time to GA");
  }

以下是控制台中打印的消息。 GoogleAnalytics 2.0b4-[GAIDispatcher dispatchComplete:withStartTime:withRetryNumber:withResponse:withData:withError:](GAIDispatcher.m:415)調試:已成功調度匹配/ GAIHit / p479(0次重試)。 請幫我。

在官方文檔中,該示例使用的方法與您在此處使用的方法不同。

- (void)onLoad:(NSTimeInterval *)loadTime {
    [tracker sendTimingWithVariableCategory:@"resources"
                            withTimeInterval:loadTime
                                    withName:@"high scores"
                                   withLabel:nil];
    ... // The rest of your onLoad: code.
}

檢查事項:

  • 確保您使用的是最新版本的SDK
  • 確保將loadTime強制轉換為NSTimeInterval,SDK嚴格限制了類型。

這可行。 Google在文檔中有錯誤。 NSTimeInterval是double,他們的SDK需要整數。 他們網站上的示例具有誤導性。

- (void)onLoad:(NSTimeInterval *)loadTime {

    NSNumber* timeInterval = [NSNumber numberWithInt:((int) (loadTime * 1000))];
    [tracker sendTimingWithVariableCategory:@"resources"
                            withTimeInterval:timeInterval
                                    withName:@"high scores"
                                   withLabel:nil];
    ... // The rest of your onLoad: code.
}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM