User Timings

This developer guide describes how to measure user timings with the Google Analytics SDK v4 for Android.

Overview

Measuring user timings provides a native way to measure a period of time in Google Analytics. This can be useful to measure resource load times, for example.

User timings have the following fields:

Field Name Type Required Description
Category String Yes The category of the timed event
Value long Yes The timing measurement in milliseconds
Name String Yes The name of the timed event
Label String No The label of the timed event

User timing data can be found primarily in the App Speed User Timings report.

Implementation

To send a user timing to Google Analytics, create a TimingBuilder and use a Tracker to send it.

// Get tracker.
Tracker t = ((AnalyticsSampleApp) getActivity().getApplication()).getTracker(
    TrackerName.APP_TRACKER);

// Build and send timing.
t.send(new HitBuilders.TimingBuilder()
    .setCategory(getTimingCategory())
    .setValue(getTimingInterval())
    .setVariable(getTimingName())
    .setLabel(getTimingLabel())
    .build());

See Advanced Configuration for details on the getTracker method.