Jump to

SDK: Users and metadata

Two kinds of data can go with a response:

Comparison table
userId, userEmailmetadata
DescribesThe respondentThis response
Stored onThe sessionThe response
Set ininit()init() or open()
Exampleuser_123, jane@example.com{ plan: 'pro', orderId: 'A-42' }
ftools('init', {
  surveyId: '__SURVEY_ID__',
  publishableKey: '__PUBLISHABLE_KEY__',
  userId: 'user_123',
  userEmail: 'jane@example.com',
  metadata: { plan: 'pro' }
});

userId and userEmail

  • A known userEmail skips the survey's contact screen, if the survey has one. A known userId alone does not.
  • If the survey doesn't allow repeat responses, userId recognizes a returning respondent across sessions. Without it, the check works only within one session.
  • Both are read once, at init().

metadata

  • A flat object: string keys, values are strings, numbers or booleans. No nested objects, arrays or null.
  • metadata from init() goes with every response of that survey on the page. metadata passed to open() replaces it for that opening; the two are not merged.
  • page_url is reserved: the SDK always sets it to the current page URL.

With Manual event tracking on, pass metadata to open() at the moment you know the most, for example right after a checkout:

ftools('open', '__SURVEY_ID__', {
  metadata: { orderId: 'A-42' }
});