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
| Parameter | Type | Description |
|---|---|---|
options.surveyId | string | Survey ID from the dashboard. |
options.publishableKey | string | Publishable API key (pk_...) from the dashboard. |
options.root | string | HTMLElement | Container for embed mode — a CSS selector or an element reference. Omit for popup mode. |
options.metadata | object | Custom data attached to the survey response. See Custom variables. |
options.channel | string | Override the channel (web-popup, web-inline, ...). Defaults to web-popup, or web-inline when root is set. |
options.userId | string | Optional identifier for the current user, attached to the session. |
options.userEmail | string | Optional email for the current user, attached to the session. |
Popup mode
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.