Advanced Usage
The documentation listed here is for Version 2 of the JavaScript Tracker. Version 3 is now available and upgrading is recommended.
This section covers the more advanced elements of the JavaScript Tracker.
šļø Optional timestamp argument
Since 2.7.0 eachĀ track...()Ā method supports an optional timestamp as its final argument; 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: