Global nxt1 Object

There is one window.nxt1 object per page. Its settings apply to every NXT element on the page.

Getting a Reference to the Global nxt1 Object

window.nxt1 exists once the embed has started. When it starts, the embed dispatches the event nxt1:initialized on window, with the object in event.detail.nxt1. The event fires once, so check for window.nxt1 first in case your code runs later:

function withNxt1(callback) {
  if (window.nxt1) {
    callback(window.nxt1)
  } else {
    window.addEventListener('nxt1:initialized', (event) => callback(event.detail.nxt1), { once: true })
  }
}

Available Methods

setIdentityTracking(mode: 'full' | 'functional' | 'off')

Switches the identity-tracking mode for the whole page without a reload. Throws an error for any other value. Switching to functional or off deletes what the new mode doesn’t allow. See Consent Handling.

withNxt1((nxt1) => nxt1.setIdentityTracking('full'))

setUserId(userId: string)

Identifies a reader who is logged in on your website, with an id from your own system.

  • The id is sent with poll votes, quiz answers and submissions of forms that accept one response per reader, in every mode. There it takes precedence over the anonymous id, so a logged-in reader can vote in a poll only once, whichever device they use.
  • The id is sent with analytics events only in the full mode.
withNxt1((nxt1) => nxt1.setUserId('user-123'))

Call it before the reader votes or submits. Don’t use an email address or another personal detail as the id.