Search code examples
google-analyticsgoogle-analytics-firebase

GoogleAnalytics track time between events


I am using GA on an Android app but this question can be relevant to all platfroms.

I track an event the usual way:

t.send(new HitBuilders.EventBuilder()
.setCategory(getString(categoryId))
.setAction(getString(actionId))
.setLabel(getString(labelId))
.build());

Is there a way to see a report of how much time has passed between such 2 events?


Solution

  • What I eventually did was tracking the time in the code and then report it like this:

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

    This will give you a report in the App Speed section of the Behavior section in the reporting tab.

    However, another problem arose regarding custom reporting of timed events which is described here: GoogleAnalytics HitBuilders.TimingBuilder