Collecting data with Trackers and Webhooks

  1. Home
  2. Docs
  3. Collecting data with Trackers and Webhooks
  4. Trackers – collecting data from your own applications
  5. JavaScript Trackers (Web and Node.js)
  6. JavaScript Tracker
  7. JavaScript Tracker v2 Reference
  8. Advanced Usage
  9. Optional timestamp argument

Optional timestamp argument

Documentation for latest release

The documentation listed here is for Version 2 of the JavaScript Tracker. Version 3 is now available and upgrading is recommended.

Documentation for Version 3

v2 to v3 Migration Guide

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.

If you do not pass this timestamp in as an argument, then the JavaScript Tracker will use the current time to be the timestamp for the event.

Here is an example tracking a structured event and supplying the optional timestamp argument.

window.snowplow("trackSelfDescribingEvent", { schema: "iglu:com.acme/event/jsonschema/1-0-0", data: {"type": "user_action"} }, [], 1368725287000 );
Code language: CSS (css)

Timestamp is counted in milliseconds since the Unix epoch – the same format as generated by new Date().getTime().

Also you can attach a true timestamp to the event, replacing the device timestamp. For example:

window.snowplow("trackSelfDescribingEvent", { schema: "iglu:com.acme/event/jsonschema/1-0-0", data: {"type": "user_action"} }, [], { type: 'ttm', value: 1368725287000 } );
Code language: CSS (css)

Above will attach ttm (true_tstamp) parameter instead of default dtm. You can also use, plain number or { type: 'dtm', value: tstamp } to send dvce_created_tstamp.

If you’d like to learn more about Snowplow BDP you can book a demo with our team, or if you’d prefer, you can try Snowplow technology for yourself quickly and easily.