Skip to content

JavaScript API reference ​

After installation, the browser creates window.FlowtomateWidget. To send IDs, email addresses, and events, start with the step-by-step guide. Use your project's installation snippet for the script URL, public key, and API URL in these examples.

MemberResultPurpose
versionstringThe version of the loaded widget.
ready()Promise<void>Wait for the first loading cycle. Completion does not prove that content was received.
refresh()Promise<void>Fetch settings and content again. Handle errors with try/catch.
identify(userId, attributes?)Promise<void>Send a stable user ID and their string fields, including email.
setTraits(attributes)Promise<void>Update individual string fields for an already identified user.
setTheme(theme)voidPass 'light' or 'dark' for the workspace theme; applies immediately without waiting for ready().
setConsent(state)voidPass 'granted', 'denied', or 'unknown' based on the user's decision.
reset(options?)Promise<void>Reset the user on sign-out. The { clearConsent: true } option also removes the consent choice.
track(name, properties?)voidSend an event; the result does not confirm delivery.
openPopup(id)Promise<boolean>Open a popup with manual launch enabled.
startTour(id)Promise<StartTourResult>Attempt to start a tour and get its status.
openOnboarding(id)Promise<{ ok: true } | { ok: false; code: string }>Open published onboarding with manual launch enabled.
closeOnboarding(id)voidClose the displayed onboarding.
registerOnboardingAction(name, handler)() => voidConnect a product command; returns a function that removes the handler.
openChecklist(id)voidOpen a loaded checklist.
openFeedback(idOrKey)voidOpen a feedback form by ID or key.
destroy()voidRemove the widget from the page. Do not use the old object afterward.

For identify and setTraits, attributes values must be strings. For example, pass seats: '12'. track also accepts numbers, booleans, null, and arrays of strings or numbers. See the events article for the full limits.

ready() waits for the first loading cycle, but the widget handles any network error from that cycle internally. If you need fresh content, call await refresh() and handle the error. Before switching accounts, wait for await reset(), then call identify. See consent and manual launch for details about consent and the results of manual opening.

Customer workspace theme ​

In Appearance, choose “Match customer workspace” → “Through SDK”. Pass the current theme before embedded content first appears:

html
<script>
window.flowtomate = window.flowtomate || function (...args) {
  window.flowtomate.q.push(args);
};
window.flowtomate.q = window.flowtomate.q || [];
window.flowtomate('setTheme', 'dark');
</script>
<script async src="https://cdn.flowtomate.com/widget/v1/widget.js"
  data-flowtomate-key="pub_live_REPLACE_WITH_YOUR_KEY"
  data-flowtomate-api="FLOWTOMATE_API_URL_FROM_YOUR_SNIPPET"></script>

Replace dark with your application's current value. Send the new value through the same command on theme changes. Only light and dark are accepted; invalid values are ignored and the last valid value is retained. Without a value, the light palette is used. The theme is not stored in the visitor profile.

SDK signals do not change the appearance in fixed mode or when “Page marker” is selected. Theme changes preserve open forms, focus and progress. Explicit content colors retain priority.

Early call queue ​

If your website code needs to issue a command before widget.js loads, create a queue before the widget tag:

html
<script>
window.flowtomate = window.flowtomate || function (...args) {
  window.flowtomate.q.push(args);
};
window.flowtomate.q = window.flowtomate.q || [];
</script>
<script async src="https://cdn.flowtomate.com/widget/v1/widget.js"
  data-flowtomate-key="pub_live_REPLACE_WITH_YOUR_KEY"
  data-flowtomate-api="FLOWTOMATE_API_URL_FROM_YOUR_SNIPPET"></script>

The queue accepts setTheme, identify, setTraits, setConsent, reset, track, openPopup, startTour, openOnboarding, closeOnboarding, and registerOnboardingAction. An example after the user has actually consented:

js
window.flowtomate('setConsent', 'granted');
window.flowtomate('identify', 'user_42', { email: 'anna@example.com' });

Early setTheme, identify, setTraits, and setConsent calls affect the first load. After installation, setTheme applies synchronously without waiting for ready(). The widget executes the other commands after ready(). Before the script loads, the queue does not return method results; after loading, its calls are also unsuitable for error handling. If you need the result of openPopup, the status from startTour, or confirmation that reset has completed, call the method through window.FlowtomateWidget with await. Do not queue ready, refresh, openChecklist, openFeedback, destroy, or version.