Install as a plain iframe
Frame the survey conversation page directly when your page cannot run the embed script, what the frame still reports to your page, and what only the script can do.
Frame the conversation page with ?embed=1 on the URL. No script, and only frame-src in your
Content-Security-Policy.
<iframe
src="https://ask.betterfeedback.ai/s/YOUR_SURVEY_ID?embed=1"
allow="microphone; autoplay"
style="width:100%;height:640px;border:0"
></iframe>?embed=1 tells the page it sits inside a frame that listens. Without it, the page behaves
exactly as the standalone link does.
What the frame reports
The page posts the same messages the widget shell receives, as
{ "type": "bf:<name>", "v": 1, "surveyId": "…", … }, to the window that frames it. Read them
with a message listener and check the origin.
window.addEventListener("message", (event) => {
if (event.origin !== "https://ask.betterfeedback.ai") return;
if (event.data?.type === "bf:completed") {
/* event.data.redirectUrl, when the survey redirects on completion */
}
});The names and payloads are the events table on JavaScript API.
What a plain iframe cannot do
- Pass the respondent's email or context. Those travel only through the script or the element; see Respondent context.
- Theme the conversation from attributes or host CSS. A one-off themed link is still possible:
/s/YOUR_SURVEY_ID?c=<base64url JSON>where the JSON is{ "v": 1, "c": { "accent": "#e11d48" } }. That link never carries email or context. - Size itself. Set a height; the page does not resize a bare frame.
- Use
betterfeedback("on", …)or any other command. Messages are the only channel.
Content-Security-Policy
frame-src https://ask.betterfeedback.ai;Voice mode needs allow="microphone" on the frame, as in the snippet above, and a
Permissions-Policy header on your page must not exclude microphone. Leave microphone out of
allow for a text-only frame.
Next.js and React
Load the BetterFeedback embed script in a Next.js or React application, let the page own mounting with the JavaScript API, or render the element in JSX, with the queue stub that makes early calls safe.
Configuration
The four layers of embed configuration, their precedence, and every option the element accepts, rendered from the descriptor the widget itself reads.