Developer Docs

SDK: Website Survey


The Formbricks JS SDK is a 2-in-1 SDK for seamlessly integrating both App Surveys and Website Surveys into your projects. In this section, we'll explore how to leverage the SDK specifically for website surveys.



npm install @formbricks/js


Initialize Formbricks

Initialize the Formbricks JS Client specifically for website surveys, ideal for public-facing websites:

Initialize Formbricks

import formbricks from "@formbricks/js/website";

  environmentId: "<your-environment-id>", // required
  apiHost: "<your-api-host>", // required
  attributes: {
    // optional
    language: "de", // optional

The moment you initialise Formbricks, your users will start seeing surveys that get triggered on simpler actions such as on New Session, Page Exit, & other custom actions!

Track Action

Track session actions to trigger surveys based on their interactions on your website, such as button clicks or scrolling:

formbricks.track("Clicked on Claim");


Reset the current instance and fetch the latest surveys and state again:


Register Route Change:

Listen for page changes and dynamically show surveys configured via no-code actions in the Formbricks website:


Debug Mode

To enable debug mode in Formbricks, add ?formbricksDebug=true to your app’s URL.

For example, if you’ve integrated Formbricks JS to your app hosted at, then change the URL to and refresh the page, now view the console logs to see the debug mode live in action.

This activates detailed debug messages in the browser console, providing deeper insights into Formbricks' operation and potential issues.

If you have any questions or need help, feel free to reach out to us on our Discord

Was this page helpful?