I am trying to track my app speed using Google analytics but i could not see anything under app speed in my google analytics account. I have tracked the other parameters like events,crashes and exceptions. For those parameter am able to see the reports generated in my google analytic account. Following is the code what i am using to send event timing.
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");
}
Following is the message printed in the console.
GoogleAnalytics 2.0b4 -[GAIDispatcher
dispatchComplete:withStartTime:withRetryNumber:withResponse:withData:withError:]
(GAIDispatcher.m:415) DEBUG: Successfully dispatched hit /GAIHit/p479
(0 retries).
Provide me any sample code if u have.
Please help me in that. Thanks in advance.
I found that the interval had to be a whole number. It's expecting milliseconds but NSTimeInterval is seconds so it tries to send it as "3.1234" but if you convert it to whole milliseconds it will send it as 3123 and you should see results. To convert I used (GA V3)
[tracker send:[[GAIDictionaryBuilder createTimingWithCategory:category interval:@((int)(interval * 1000)) name:name label:label] build]]
Did you happen to see the real time data tab in GA dashboard??? They show the last 30 minutes usage data. Later it updates in your Google analytics dashboard. I have worked with flurry, Google analytics, I find GA is better and faster. Keep trying!!!.
Your implementation seems fine. I don't think it's the problem (and as you get the basic events, it's probably not a problem of initialization). I have the same way to log the timing events (you can find my code below if you want to compare).
What I can tell you is:
1/ It's a "beta" version (yes ok, all things @google are in beta xD), pretty unstable and events take time to be displayed in the administration (I don't see any events for the 18 february yet, for example). At least, more than for a website with similar stats.
2/ I can't display the time events on more than 2 days, or it displays me some errors ^^ (probably too many datas asked for a large timezone)
3/ If there is no label, don't put the category, just set nil. Same for the name. I think they are both optional parameters. And it'll slow down the display of your analytics when you have more stats.
4/ For big set of datas, time events are calculated on part of your visits. But it shouldn't be your problem right now ^^
http://support.google.com/analytics/bin/answer.py?hl=en&answer=1042498
Wait 2 days. If you still don't see anything, try to contact a google analytics representative. Or take the "risk“ to submit it like it is.
My implementation
(in case it could help)
+ (void)trackGoogleTimingInCategory:(NSString *)category withTimeInterval:(NSTimeInterval)time withName:(NSString *)name withLabel:(NSString *)label {
//
if (![ category isKindOfClass:[ NSString class ] ])
return;
NSLog(@"[%@] %@ time=%f (%@)", category, name, time, label);
//
if (![ name isKindOfClass:[ NSString class ] ])
name = nil;
if (![ label isKindOfClass:[ NSString class ] ])
label = nil;
//
[ [ [ GAI sharedInstance ] defaultTracker ] sendTimingWithCategory:category withValue:time withName:name withLabel:label ];
}
For the time calculation, I do the same way:
NSTimeInterval timeInterval = [ [ NSDate date ] timeIntervalSinceDate:timeStart ];
You must wait at least 24 hours for data to become available in your Google Analytics dashboard, unless you have a GA Premium account:
http://www.google.com/analytics/premium/features.html
I had the same issue with Google Analytics component for Xamarin on iOS, but got it working using NSNumber.FromInt32:
var start = DateTime.Now;
// do operation
var finish = DateTime.Now;
var timeElapsed = finish.Subtract (start);
GAI.SharedInstance.DefaultTracker
.Send(GAIDictionaryBuilder.CreateTiming(
"Storage",
NSNumber.FromInt32((int)timeElapsed.TotalMilliseconds),
"LoadItems", null)
.Build());