2013-02-14 82 views
0

我試圖跟蹤我的應用程序的速度使用谷歌分析,但我看不到任何應用程序的速度在網站上。但我可以看到其他參數,如事件,崩潰和異常。以下是我用來發送事件時間的代碼。iOS谷歌分析不跟蹤應用程序速度

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

以下是在控制檯打印的信息。 (GAIDispatcher.m:415)調試:成功發送命中/ GAIHit/p479(0次重試)。Google Analytics(分析)2.0b4 - [GAIDispatcher dispatchComplete:withStartTime:withRetryNumber:withResponse:withData:withError:] 請幫幫我。

回答

0

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

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

檢查事項:

  • 確保您使用的是最新版本的SDK的。
  • 請確保您將loadTime轉換爲NSTimeInterval,但SDK對類型有點嚴格。
+0

嗨愛德華多,感謝您的回答。我會努力並讓你知道。 – Karthick 2013-02-18 05:23:51

0

This works。 Google在doc中有錯誤。 NSTimeInterval是雙倍的,他們的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. 
}