Jump to

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'
});
Comparison table
OptionTypeRequiredDefaultDescription
surveyIdstringyesSurvey ID from the dashboard.
publishableKeystringyesPublishable key (pk_...) from the dashboard.
rootstring | HTMLElementContainer for embed mode: a CSS selector or an element. See Survey modes.
userIdstringYour ID of the current user, stored on the session. See Users and metadata.
userEmailstringEmail of the current user, stored on the session.
metadataRecord<string, string | number | boolean>Data stored on every response of this survey. page_url is reserved. See Users and metadata.
languagestringbrowser languageBCP-47 tag (de, pt-BR) for the survey texts. See Language.
theme'light' | 'dark' | 'auto''light'Color theme. See Theme.
classNamestringClass added to this widget's host next to .ftools-survey. See Custom styles.
allowScreenshotsbooleantruefalse 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 the Accept-Language header, 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. Without language, they are in English.
  • With language set to Arabic, Persian or Hebrew (ar, fa, he), the survey renders right to left.