SDK: Initialization
ftools('init', options)
Sets up a survey. You can call it before the SDK loads: the call waits in the queue.
ftools('init', {
surveyId: '__SURVEY_ID__',
publishableKey: '__PUBLISHABLE_KEY__'
});
ftools('init', {
surveyId: '__SURVEY_ID__',
publishableKey: '__PUBLISHABLE_KEY__',
root: '#container'
});| Option | Type | Required | Default | Description |
|---|---|---|---|---|
surveyId | string | yes | Survey ID from the dashboard. | |
publishableKey | string | yes | Publishable key (pk_...) from the dashboard. | |
root | string | HTMLElement | Container for embed mode: a CSS selector or an element. See Survey modes. | ||
userId | string | Your ID of the current user, stored on the session. See Users and metadata. | ||
userEmail | string | Email of the current user, stored on the session. | ||
metadata | Record<string, string | number | boolean> | Data stored on every response of this survey. page_url is reserved. See Users and metadata. | ||
language | string | browser language | BCP-47 tag (de, pt-BR) for the survey texts. See Language. | |
theme | 'light' | 'dark' | 'auto' | 'light' | Color theme. See Theme. | |
className | string | Class added to this widget's host next to .ftools-survey. See Custom styles. | ||
allowScreenshots | boolean | true | false hides the screenshot control. See Screenshots. | |
channel | 'web-popup' | 'web-inline' | 'direct-link' | 'qr-code' | 'email' | 'web-popup' or 'web-inline' | Channel recorded on responses. The SDK drops any other value and sends no channel. |
A second init() with the same surveyId is ignored while the first widget exists. Call destroy() first.
Language
The survey texts you write in the dashboard come from the backend in the visitor's language. By default the backend picks it from the browser's Accept-Language header. Pass language when your app knows the visitor's language better, for example after an in-app language switch:
ftools('init', {
surveyId: '__SURVEY_ID__',
publishableKey: '__PUBLISHABLE_KEY__',
language: 'de'
});- The SDK sends the tag to the backend as is. The backend matches it whole, then by its base language (
de-AT→de). A tag it can't match is ignored: the backend falls back to theAccept-Languageheader, then to the survey's default language. - The SDK's own labels (default Send and Skip, the screenshot control, screen-reader labels) come in 50 languages and follow
language. Withoutlanguage, they are in English. - With
languageset to Arabic, Persian or Hebrew (ar,fa,he), the survey renders right to left.