Skip to Content
BetterFeedback Docs

Embed the conversation on your site

What the BetterFeedback embed is, the three ways to put a survey conversation on your own page, what can be configured from where, and the pages in this section that cover each part.

The embed puts a survey conversation on a page you own. Every survey already has a page at https://ask.betterfeedback.ai/s/{surveyId}; the embed is one script tag, https://ask.betterfeedback.ai/widget.js, that renders a <betterfeedback-widget> element on your page and loads that conversation inside it. The element draws the launcher, the panel and its header in your page's DOM, inside a shadow root, so your CSS stays out of it and its CSS stays out of your page. The conversation itself runs in an iframe of ask.betterfeedback.ai, which is where the voice connection and the microphone permission live.

The survey id is the last segment of the survey's /s/ link.

Three ways to add it

WayForPage
One script tag with data-surveyAny site. Floats in a corner, or renders inline in place of a form with data-targetPlain HTML
The element, placed by youControl over where it sits in the DOM, or a React or Next.js page that owns mountingNext.js and React
A plain iframeA page that cannot run scripts, or a CSP that allows frames onlyPlain iframe

There is no npm package and no React wrapper: the script tag and the element are the whole API, and they work the same in every framework.

What is configured where

LayerSet byReaches
Stored appearanceBetterFeedback, on the survey, on requestEvery page the survey is on
AttributesThe embed code, per pageThat page
JavaScriptbetterfeedback("config", …) at runtimeThat page, until reload
CSS--bf-* tokens and ::part() rules on your pageWins over all of the above
SlotsYour own markup for the launcher, header or footerReplaces that region of the shell

Configuration lists every option and the precedence order; Theming the tokens, parts, slots and copy keys; Behaviour what each mode and setting does; JavaScript API the commands and events; Respondent context how to hand over what your page already knows about the visitor.

What it does on the page

  • Loads the conversation iframe when the panel first opens in floating mode, and at once in inline mode.
  • Dispatches a betterfeedback:<name> event for everything that happens: ready, started, completed, ended, error and resize. A tag manager can read them from document.
  • In inline mode with auto height, sizes the frame to the conversation instead of scrolling inside a fixed box.
  • Asks your Content-Security-Policy for two allowances only, script-src and frame-src for https://ask.betterfeedback.ai. The API, the voice connection and the microphone prompt all belong to the frame's origin, not yours.

Size and dependencies

widget.js has no dependencies and its build fails above 15 KB gzipped.

On this page