1

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?

JulianHarty
  • 3,178
  • 3
  • 32
  • 46
CodeMonkey
  • 11,196
  • 30
  • 112
  • 203
  • [This support doc](https://support.google.com/analytics/answer/2709829?hl=en) mentions: "*Specify time in seconds, but it appears as hh:mm:ss in your reports.*" Also as mentioned in other post, see [this SO answer](http://stackoverflow.com/questions/22721284/event-value-google-analytics-measurement-protocol/22722302#22722302) about how it is aggregated (post is about event `Value` but it works the same way for custom metrics too) – CrayonViolent May 19 '15 at 13:02
  • Your comment better fit as an answer. if you move it to be an answer, I still got some issues - About the formatting, if it's hh:mm:ss then it's not logical. How can it be that in the app speed regular report, I see the event as several seconds but in the custom report it says 9 hours? And another problem is that in the report I can't seem to find how to view an avarage time. If a metric is a total sum of the time, how can I see the avarage (and just to emphasize again - I know I can see the avarage time at the app speed but not in the custom report) – CodeMonkey May 19 '15 at 13:20
  • Well it looks like you are sending a timestamp difference that includes milliseconds, so you need to round/truncate off the milliseconds before sending in the value, or else e.g. GA is going to see 1000 as one thousand seconds (~16:40) not 1 second (00:01) – CrayonViolent May 19 '15 at 14:23
  • so the problem is in the value of the metric? the setValue method should receive the value in ms but the setCustomMetric should receive the value in seconds? That could explain the hh:mm:ss format – CodeMonkey May 19 '15 at 14:52
  • The `Value` argument for setting an event is the same concept as the `Value` argument for setting a custom metric. The only difference is that the former is explicitly bound to the event. Beyond that, they are same thing, processed and displayed in reports the same way. They should *both* be in seconds. I see you are using the same value (in ms) for both of them but you see diff numbers in the reports. That must be something else then, e.g. diff in what dimensions you are using, or the scope you are using for each one. – CrayonViolent May 19 '15 at 16:51
  • Do you want to sum everything up as an answer and I'll accept it? – CodeMonkey May 24 '15 at 20:04

1 Answers1

1

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.

CrayonViolent
  • 32,111
  • 5
  • 56
  • 79