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
| Way | For | Page |
|---|---|---|
One script tag with data-survey | Any site. Floats in a corner, or renders inline in place of a form with data-target | Plain HTML |
| The element, placed by you | Control over where it sits in the DOM, or a React or Next.js page that owns mounting | Next.js and React |
| A plain iframe | A page that cannot run scripts, or a CSP that allows frames only | Plain 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
| Layer | Set by | Reaches |
|---|---|---|
| Stored appearance | BetterFeedback, on the survey, on request | Every page the survey is on |
| Attributes | The embed code, per page | That page |
| JavaScript | betterfeedback("config", …) at runtime | That page, until reload |
| CSS | --bf-* tokens and ::part() rules on your page | Wins over all of the above |
| Slots | Your own markup for the launcher, header or footer | Replaces 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 fromdocument. - 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-srcandframe-srcforhttps://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.