Jump to

ftools('init', options)

Initializes a survey. Asynchronous — returns a Promise, but the call itself can be made before the SDK script loads (it will be queued and replayed once ready).

ftools('init', { surveyId: 'SURVEY_ID', publishableKey: 'API_KEY' });
ftools('init', { surveyId: 'SURVEY_ID', publishableKey: 'API_KEY', root: '#container' });

Parameters

Comparison table
ParameterTypeDescription
options.surveyIdstringSurvey ID from the dashboard.
options.publishableKeystringPublishable API key (pk_...) from the dashboard.
options.rootstring | HTMLElementContainer for embed mode — a CSS selector or an element reference. Omit for popup mode.
options.metadataobjectCustom data attached to the survey response. See Custom variables.
options.channelstringOverride the channel (web-popup, web-inline, ...). Defaults to web-popup, or web-inline when root is set.
options.userIdstringOptional identifier for the current user, attached to the session.
options.userEmailstringOptional email for the current user, attached to the session.
ftools('init', {
  surveyId: 'SURVEY_ID',
  publishableKey: 'API_KEY'
});

The survey shows automatically based on the triggers configured in the dashboard, or manually via open().

Embed mode

Pass root to render the survey inline inside a container you provide:

// CSS selector
ftools('init', {
  surveyId: 'SURVEY_ID',
  publishableKey: 'API_KEY',
  root: '#my-container'
});

// HTMLElement reference
ftools('init', {
  surveyId: 'SURVEY_ID',
  publishableKey: 'API_KEY',
  root: document.getElementById('my-container')
});

root accepts either a CSS selector string or a direct HTMLElement reference. Use an element reference if the container lives inside a Shadow DOM — document.querySelector cannot traverse into Shadow DOM from the main document.

See Survey modes for the full behavior differences between popup and embed.