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 v3 Reference
  8. Advanced Usage
  9. Optional timestamp argument

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.

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 self describing event and supplying the optional timestamp argument.

snowplow("trackSelfDescribingEvent", { event: { schema: "iglu:com.acme/event/jsonschema/1-0-0", data: { type: "user_action" } }, timestamp: 1368725287000 });
Code language: JavaScript (javascript)

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:

snowplow("trackSelfDescribingEvent", { event: { schema: "iglu:com.acme/event/jsonschema/1-0-0", data: { type: "user_action" } }, timestamp: { type: 'ttm', value: 1368725287000 } });
Code language: JavaScript (javascript)

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

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