Search code examples
androidgoogle-analyticsgoogle-analytics-firebase

GoogleAnalytics HitBuilders.TimingBuilder


I'm using GA for an Android App.

I'm trying to use user timings to report how much time has passed for some actions in my code, so what I basically do is this:

At some point in the code I get System.currentTimeMillis(), at another point I do it again and subtract the latter from the former to get how much time has passed. I then report it to GA like this:

long time1 = System.currentTimeMillis();
...
long time2 = System.currentTimeMillis();
long timingValue = time2 - time1;
tracker.send(new HitBuilders.TimingBuilder()
            .setCategory(timingCategory)
            .setValue(timingValue)
            .setVariable(timingVariable)
            .setLabel(timingLabel)
            .setCustomDimension(1,1)
            .setCustomMetric(1, timingValue).build());

When I look at the "App Speed" section everything looks fine. It seems to report a logical average time in seconds like I expect.

The problem is that I want to use several dimensions (the secondary dimension is not enough) so I created all these timings as metrics as well so I can see them in a custom report. When I look at the report, the time I see there is 09:43:39 and I'm not sure what's the format here. Is it seconds:tenth of a second:hundredth of a second? And How can I see the average time of these metrics? I'm not sure if what I see is only the total amount of time or something else?


Solution

  • A Value of type time (for both events and custom metrics) should be passed as a whole number (no commas or decimals) representing seconds. So for example, 10 seconds should be 10, and 5 minutes should be 300, etc. Note that in the reports, it will be formatted as hh:mm:ss.