Forms

Embed a Zoie form with the form widget script: the exact snippet, choosing where the form renders, script timing, the CORS and Allowed Domains rules, how an API key affects the embed, the data it sends and the CSP it needs.

The form widget draws one of your Zoie forms into your own page and sends each entry to Zoie as a lead. The fields, steps, conditions, colours and background all come from the form builder and load fresh on every page view. For the publish panel, see Embedding forms. For the HTTP endpoints the widget calls, see the Forms API.

Install

  1. In the form builder, click Publish Form and open the Embed Code tab.
  2. Click Copy at the top right of the Html box.
  3. Paste the code into your page, and add a container where the form should go. See Choose where the form appears.

Copy puts four tags on your clipboard, although the panel only displays the last one:

<!-- Zoie Form Widget -->
<script src="https://unpkg.com/react@18/umd/react.production.min.js"></script>
<script src="https://unpkg.com/react-dom@18/umd/react-dom.production.min.js"></script>
<link
  rel="stylesheet"
  href="https://unpkg.com/react-phone-input-2/lib/style.css"
/>

<script
  src="https://us.zoie.ai/form-widget-bundle.js"
  form_id="6f1c2d3e-8a4b-4c1d-9e2f-0a1b2c3d4e5f"
  defer>
</script>
TagNeeded?
form-widget-bundle.js with form_idYes. This is the form.
The react-phone-input-2 stylesheetYes, if the form has a phone field. It styles the country picker and dial code.
The two React scriptsNo. The bundle has its own copy of React and doesn’t use these, so you can leave them out.

The form ID is the form’s UUID. It is also the last part of the form’s share link.

Choose where the form appears

The form renders into an element with the ID static-form-widget-container. If your page doesn’t have one, the widget creates it at the end of <body>, so the form appears at the bottom of the page wherever you pasted the script. To put it somewhere specific, add the container yourself:

<section class="contact">
  <h2>Book a free consultation</h2>
  <div id="static-form-widget-container"></div>
</section>

<script
  src="https://us.zoie.ai/form-widget-bundle.js"
  form_id="6f1c2d3e-8a4b-4c1d-9e2f-0a1b2c3d4e5f"
  defer>
</script>

The form fills its container with a section at least as tall as the screen less 60 px, in the form’s background colour or image. In the middle sits a white card up to 700 px wide, which scrolls internally once it reaches 80% of the screen height. The container is given position: relative and z-index: 2147483000, so it covers anything that overlaps it, sticky headers included.

A page can show one embedded form. A second form script renders into the same container.

When the script starts

The form widget starts on the page’s DOMContentLoaded event.

How the script is addedResult
With defer, as in the snippetStarts normally.
As a plain <script> without defer or asyncStarts normally, but holds up your page while it downloads.
With async, or added later by JavaScript, a tag manager or a single-page appIt can miss DOMContentLoaded, and then nothing renders. Call window.initFormWidget yourself once the script has loaded.
const script = document.createElement('script');
script.src = 'https://us.zoie.ai/form-widget-bundle.js';
script.onload = () => {
  window.initFormWidget({ form_id: '6f1c2d3e-8a4b-4c1d-9e2f-0a1b2c3d4e5f' });
};
document.body.appendChild(script);

More variants are in Installation snippets.

Where the form can run

Three rules decide whether the form loads and submits on your site.

Your domain must be registered with Zoie

The form’s API answers browsers only on Zoie’s own sites and on websites registered for a Zoie business. On any other site the browser blocks the response with a CORS error. The form then shows Unable to load this form with Network Error. The website chat widget doesn’t have this restriction.

A registered website covers its exact origin and its www. variant: https://example.com also covers https://www.example.com, but not https://staging.example.com. Ask Zoie support to register each domain you embed on. Changes take up to five minutes to apply. If you can’t register a domain, link to the form’s hosted page instead, which works anywhere.

Allowed Domains

The Allowed Domains box under the embed code limits the form to the sites you list. With entries, the form refuses to load or accept entries from any other site, with 403 and origin_not_allowed. An empty box allows every site that passes the CORS rule above. Matching works as for the chat widget. See Allowed domains.

No REST API key on the form

If you generate a REST API key for the form on the REST API tab, every submission to that form must carry the key. The embed and the share link can’t send one, so their entries fail with 401 and Invalid or missing API key. A key can be replaced but not removed. Use a separate form for server-to-server submissions. See Form API key.

What the form sends

DataWhen
Each field’s value, keyed by the lead field it’s mapped to, or by the field’s own IDOn submit
UTM parameters, Google Ads click IDs and the ad-consent state, collected the same way as the chat widgetOn submit, and with partial captures
The fields filled in so far, with form_status: "Abandoned Form"When the visitor leaves the page after typing something without submitting

The page-leave capture is best-effort, because browsers often cancel requests from a closing page. The embed sends it whether or not abandoned-lead collection is switched on for the form. It is stored as an incomplete form entry and never creates a lead. See Abandoned form settings.

The form reads the same ad-consent signals as the chat widget: window.ZoieWidgetConsent, a data-ad-consent attribute on a script tag, or Google Consent Mode. See Ad consent.

After a successful submit, the card shows Thank you! and Your response has been submitted. We’ll be in touch shortly. An error from Zoie is shown to the visitor as a message. A contact on the business’s block list sees We could not submit this form. Please contact us directly.

Content Security Policy

DirectiveAllowUsed for
script-srchttps://us.zoie.aiThe bundle. Add https://unpkg.com only if you keep the React scripts.
style-src'unsafe-inline' https://unpkg.comThe widget’s own <style> elements, and the phone-field stylesheet.
connect-srchttps://api-us.zoie.aiLoading the form and sending entries.
img-srchttps: data:Your logo and background image, and the country flags in the phone field.