Advanced Usage
This section covers the more advanced elements of the JavaScript Tracker.
šļø Optional timestamp argument
EachĀ track...()Ā method supports an optional timestamp property; this allows you to manually override the timestamp attached to this event. The timestamp should be in milliseconds since the Unix epoch.
šļø Tracker Callbacks
If you call snowplow with a function as the argument, the function will be executed when sp.js loads:
šļø Getting the most out of performance timing
TheĀ domComplete,Ā loadEventStart, andĀ loadEventEndĀ metrics in the NavigationTiming API are set to 0 until after every script on the page has finished executing, including sp.js. This means that the corresponding fields in the PerformanceTiming reported by the tracker will be 0. To get around this limitation, you can wrap all Snowplow code in aĀ setTimeoutĀ call:
šļø Using an ID service
What is an ID service ?
šļø Creating a white-label build
Every time the snowplow tracker loads on the page, a queue-like object GlobalSnowplowNamespace is initialised on the global window scope. This object is then used to queue commands before the tracker snippet (sp.js) has fully loaded.