Tracking Code: Site Speed User Timing

This reference describes the method that you use to track periods of time in Google Analytics. The site speed user timing reports are designed specifically to help developers understand the latency, or time spent, making AJAX requests or loading web resources. Read the Site Speed User Timings Developer Guide for details describing how to use this method.

GATC User Timing Method

_trackTiming(category, variable, time, opt_label, opt_sampleRate)

Constructs and sends the user timing tracking call to the Google Analytics Tracking Code. For example if the jQuery library took 20 milliseconds to load from the Google Content Network, and you wanted data to be sent for 50% of visitors, you would call:

_gaq.push([‘_trackTiming’, ‘jQuery’, ‘Load Library’, 20, ‘Google CDN’, 50]);

Parameter Details

Parameter Value Required Summary
category string yes A string for categorizing all user timing variables into logical groups for easier reporting purposes. For example you might use value of jQuery if you were tracking the time it took to load that particular JavaScript library.
variable string yes A string to indicate the name of the action of the resource being tracked. For example you might use the value of JavaScript Load if you wanted to track the time it took to load the jQuery JavaScript library. Note that same variables can be used across multiple categories to track timings for an event common to these categories such as Javascript Load and Page Ready Time, etc.
time number yes The number of milliseconds in elapsed time to report to Google Analytics. If the jQuery library took 20 milliseconds to load, then you would send the value of 20.
opt_label string no A string that can be used to add flexibility in visualizing user timings in the reports. Labels can also be used to focus on different sub experiments for the same category and variable combination. For example if we loaded jQuery from the Google Content Delivery Network, we would use the value of Google CDN.
opt_sampleRate number no A number to manually override the percent of visitors whose timing hits get sent to Google Analytics. The default is set at the same number as general site speed data collection and is based as a percentage of visitors. So if you wanted to track _trackTiming hits for 100% of visitors, you would use the value 100. Note that each hit counts against the general 500 hits per session limit.