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 Tracker
  6. Advanced Usage
  7. Methods which can be used from within a callback

Methods which can be used from within a callback

getUserFingerprint

The getUserFingerprint method returns the tracker-generated user fingerprint:

// Configure a tracker instance named "cf" snowplow_name_here('newTracker', 'cf', 'd3rkrsqld9gmqf.cloudfront.net', { appId: 'snowplowExampleApp', platform: 'web' }); // Access the tracker instance inside a callback snowplow_name_here(function () { var cf = this.cf; var userFingerprint = cf.getUserFingerprint(); doSomethingWith(userFingerprint); })

getDomainUserId

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

// Access the tracker instance inside a callback snowplow_name_here(function () { var cf = this.cf; var domainUserId = cf.getDomainUserId(); doSomethingWith(domainUserId); })

getDomainUserInfo

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

// Access the tracker instance inside a callback snowplow_name_here(function () { var cf = this.cf; var domainUserInfo = cf.getDomainUserInfo(); doSomethingWith(domainUserInfo); })

The domainUserInfo variable will contain an array with 7 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

getUserId

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

// Access the tracker instance inside a callback snowplow_name_here(function () { var cf = this.cf; var userId = cf.getUserId(); doSomethingWith(userId); })

getCookieName

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

// Access the tracker instance inside a callback snowplow_name_here(function () { var cf = this.cf; var cookieName = cf.getCookieName('id'); doSomethingWith(cookieName); })

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

getPageViewId

The getPageViewId method returns the page view id:

// Access the tracker instance inside a callback snowplow_name_here(function () { var cf = this.cf; var pageViewId = cf.getPageViewId(); doSomethingWith(pageViewId); })