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. Browser Tracker
  7. Browser Tracker v3 Reference
  8. Advanced Usage
  9. Tracker Information

Tracker Information

When initialising a tracker, you can use the returned tracker instance to access various properties from this tracker instance.

// Configure a tracker instance named "sp" const sp = newTracker('sp', '{{COLLECTOR_URL}', { appId: 'snowplowExampleApp' }); // Access the tracker properties const domainUserId = sp.getDomainUserId();
Code language: JavaScript (javascript)

Available methods on the Tracker


The getDomainUserId method returns the user ID stored in the first-party cookie:

const domainUserId = sp.getDomainUserId(); console.log(domainUserId);
Code language: JavaScript (javascript)


The getDomainUserInfo method returns all the information stored in first-party cookie in an array:

const domainUserInfo = sp.getDomainUserInfo(); console.log(domainUserInfo);
Code language: JavaScript (javascript)

The domainUserInfo variable will contain an array with 11 elements:

  1. A string set to '1' if this is the user’s first session and '0' otherwise
  2. The domain user ID
  3. The timestamp at which the cookie was created
  4. The number of times the user has visited the site
  5. The timestamp for the current visit
  6. The timestamp of the last visit
  7. The session id
  8. ID of the previous session (since version 3.5)
  9. ID of the first event in the current session (since version 3.5)
  10. Device created timestamp of the first event in the current session (since version 3.5)
  11. Index of the last event in the session (used to inspect order of events) (since version 3.5)


The getUserId method returns the user ID which you configured using setUserId():

const userId = sp.getUserId(); console.log(userId);
Code language: JavaScript (javascript)


The getCookieName method returns the complete cookie name for the domain or session cookie:

const cookieName = sp.getCookieName('id'); console.log(cookieName);
Code language: JavaScript (javascript)

The argument corresponds to the basename of the cookie: ‘id’ for the domain cookie, ‘ses’ for the session cookie.


The getPageViewId method returns the page view id:

const pageViewId = sp.getPageViewId(); console.log(pageViewId);
Code language: JavaScript (javascript)

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.