Skip to main content

Optional timestamp argument

caution
You are reading documentation for an outdated version. Here’s the latest one!
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
);

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 }
);

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`.

Was this page helpful?