Skip to main content

For AI agents: a Markdown version of this page is at https://docs.snowplow.io/docs/sources/web-trackers/previous-versions/web-trackers-v3/tracking-events/timings/generic.md. The index of all documentation pages is at https://docs.snowplow.io/llms.txt, and the index for this section is at https://docs.snowplow.io/docs/api-reference/llms.txt.

Generic timing

caution
You are reading documentation for an outdated version. Here's the latest one!

Use the trackTiming method to track user timing events such as how long resources take to load. This method is provided as part of the site-tracking plugin.

Timing events must be manually tracked.

Install plugin​

Tracker DistributionIncluded
sp.js✅
sp.lite.js❌

Download:

Download from GitHub Releases (Recommended)Github Releases (plugins.umd.zip)
Available on jsDelivrjsDelivr (latest)
Available on unpkgunpkg (latest)

Note: The links to the CDNs above point to the current latest version. You should pin to a specific version when integrating this plugin on your website if you are using a third party CDN in production.

javascript
window.snowplow('addPlugin',
"https://cdn.jsdelivr.net/npm/@snowplow/browser-plugin-site-tracking@3/dist/index.umd.min.js",
["snowplowSiteTracking", "SiteTrackingPlugin"]
);

Timing event​

Use the trackTiming method to track how long something took. Here are its arguments:

NameRequired?DescriptionType
categoryYesTiming categorystring
variableYesTimed variablestring
timingYesNumber of milliseconds elapsednumber
labelNoLabel for the eventstring

An example:

javascript
snowplow('trackTiming', {
category: 'load',
variable: 'map_loaded',
timing: 50,
label: 'Map loading time'
});

Timing events are implemented as Snowplow self describing events. Here is the schema for a timing event.

Was this page helpful?