This developer guide describes how to measure user timings with the Google Analytics SDK for Android v3.
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 | Tracker Field | Type | Required | Description |
---|---|---|---|---|
Category | Fields.TIMING_CATEGORY
|
String
|
Yes | The category of the timed event |
Value | Fields.TIMING_VALUE
|
long
|
Yes | The timing measurement in milliseconds |
Name | Fields.TIMING_VAR
|
String
|
Yes | The name of the timed event |
Label | Fields.TIMING_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, build a timing hit using
MapBuilder.createTiming()
, then send it
using send():
/* * Called after a list of high scores finishes loading. * * @param loadTime The time it takes, in milliseconds, to load a resource. */ public void onLoad(long loadTime) { // May return null if EasyTracker has not been initialized with a property // ID. Tracker easyTracker = EasyTracker.getInstance(this); easyTracker.send(MapBuilder .createTiming("resources", // Timing category (required) loadTime, // Timing interval in milliseconds (required) "high scores", // Timing name null) // Timing label .build() ); }