Skip to main content
This page is for self-serve developers and partners who show a published composition on a website. To show a workflow (a path of compositions), see Embed a workflow. To put Widgetic’s editors in your product, see UI Components. Every option of the Embed code screen is listed, with its attribute, in Embed settings.

Embed code

After you publish a composition, the dashboard (or get_embed_code in MCP) gives you a tag and script. The supported way is the CDN script plus a <widgetic> element placed where the widget should appear. There is nothing to install and no key in the page: showing a widget needs only the composition id.
  • Several widgets on one page work with one script tag.
  • data-api-url is the API the script asks for the composition. Copy it as the dashboard gives it.
  • Every other attribute is an option of the Embed code screen. Together they decide how the widget fits its place (Size and layout), where it appears (Choose how the widget appears) and when (Choose when a pop-up opens).
  • Where the widget runs. The script mounts the widget in the page when it can, and in an iframe of its own when it cannot. Add render-mode="iframe" to ask for the iframe from the start.
  • Allowed websites: if you limited the websites that may show your widgets, the script shows nothing on other websites. Your own machine and Widgetic’s own sites are always allowed, and so is a partner’s platform website with all of its subdomains. See Allowed domains.
When you cannot load a script, use the frame instead:

Paste an embed code to set the options

The Embed code screen in the dashboard shows your embed code in a box at the top, with the line “Not sure how embedding works? Learn more” just below it, and the options under that. You can paste an existing embed code into the box and the options (size, resize mode, overlay position and the rest) change to match it, which is the quickest way to edit an embed that is already on a page:
  1. Copy the embed code from your page.
  2. Click the code box in the Embed code screen.
  3. Press Cmd+V (Mac) or Ctrl+V (Windows, Linux).
The box does not accept typing, only a paste. If the text is not a Widgetic embed code, the screen says so and nothing changes. Options in the pasted code that the screen does not know are listed and left out.

Choose how the widget appears

The Embed target decides how a visitor meets the widget: The Embed code screen starts on Overlay, so a code you copy without changing it is a pop-up. A <widgetic> tag that has no embed-target is Inline.

Inline

The widget is part of the page and takes the space of its tag. This is the code at the top of this page, and Size and layout says how the box is sized.

Overlay: a pop-up

A pop-up in the middle of the window on a dimmed background, that opens when the visitor is about to leave, at most twice in 72 hours, and not on phones:
  • The tag is hidden from the first moment, so the widget never flashes in the page before the pop-up. A pop-up that never opens never loads the widget.
  • It opens when the trigger fires (Choose when a pop-up opens). It sits at the Overlay position you chose, one of nine cells of the window, 20 pixels from the edges. It is as big as width and height say, and never larger than 90% of the window.
  • The visitor can always close it: it has a close button, and Esc closes it too.
  • Add background puts a layer behind the pop-up, in the color and opacity you choose, and the page behind cannot be clicked. Without it the page stays usable while the pop-up is open.
  • View limits keep a visitor from seeing it over and over: at most Max # of views within the Time period, counted in the visitor’s browser.

Mixed: a box that follows the visitor

A widget in the page that floats in the bottom-right corner, at 320 by 180 pixels, once its place has scrolled out of view, and never on /checkout:
  • The widget is in the page from the start, and the floating box appears when the visitor scrolls it out of view. An empty space the size of the widget stays in the page, so the page does not jump. When the visitor scrolls back to that space, or closes the floating box, the widget returns to it.
  • Keep dimensions on lets the floating box keep the size the widget has in the page. Off, the Overlay resize mode, Overlay width and Overlay height size it, as in the code above. A floating box is never larger than 90% of the window.
  • Mixed has fewer options than Overlay. It has no trigger and no rules except Exclude URLs, and the device switches of View limits apply. The view limits themselves, Max # of views and Time period, count pop-ups only.

Use iframe: a frame with no script

With Use iframe on, the code is only the frame of the composition. It needs no script, so it works where scripts cannot run, but the widget cannot follow the height of its content or hear events from your page, and only Width and Height are left to set:

Size and layout

How the box of an Inline embed is sized comes from resize, width and height: A tag with no resize, or with a value that is not in the table, is a fixed box, and a tag that gives no width or height gets 400 by 300 pixels. resize and adaptive are for an Inline embed: an Overlay or a Mixed embed is not sized by them, and a pop-up or a floating box is sized as described above.
  • Height of a wide box. With fill-width or responsive, the height is height. When the tag has no Autoscale and both width and height are numbers of pixels, the height instead keeps the proportions of that width and height as the box gets wider or narrower, so a narrow box is shorter, as a picture is.
  • Autoscale (autoscale="on") makes the box as tall as the widget needs, so the widget never clips and the paragraph after it is never covered. The box starts at height, or at the height the last visit ended on so a reload does not jump, and then follows the widget between autoscale-min-height (the tag’s height unless you say otherwise) and autoscale-max-height (2000 pixels unless you say otherwise, at most 20000). A widget shown in an iframe is followed by the height it reports. Each change sends widgetic:autoscale. Off, the box stays the height of the tag. A tag that says autoscale="false" (or 0, off or no) is off too.
  • Adaptive (adaptive="480") is a breakpoint in pixels, a whole number from 1 to 10000. The tag says data-widgetic-mobile="true" while the window is that narrow or narrower, and "false" above it, and sends widgetic:adaptive once the box is made and each time the window crosses it, so your page, or a widget that listens, can switch to a narrow layout. The box itself does not change: a fixed tag stays fixed. A responsive tag without adaptive uses 480.

Choose when a pop-up opens

The Event triggers setting decides what opens an Overlay pop-up by itself (event-trigger in the tag): Pick one trigger. Besides the trigger, a pop-up can follow rules, which the visitor’s browser checks before it opens:
  • Excludes: pages it must not open on, and not again after the visitor closed it or after it opened once.
  • Visitors: new or returning visitors, the time spent on the page, the number of pages seen on your site.
  • Schedule: a range of dates, weekdays and hours of the day, by the visitor’s clock.
  • Acquisition: direct traffic only, the referrer, the page’s address, and its utm_source, utm_medium and utm_campaign.
  • View limits: at most so many views in a number of hours.
Every rule that is set has to pass, for each trigger, Manual included. The checks use the page’s address, the referrer, the clock and counters that the browser keeps in its own storage, so clearing the site’s data in the browser resets the counts and the “do not show again” flags. Embed settings lists each rule and its limits. Here is a pop-up in the bottom-right corner that opens 8 seconds after the page is ready, only on weekdays from 09:00 to 17:00 by the visitor’s clock, only for visitors who arrive from a link whose utm_campaign contains spring, never on /checkout or /cart, and not again once the visitor has closed it:

Open it from your page

With the Manual trigger the pop-up never opens by itself. Your page opens it with Widgetic.show, for example from a button, and gives it the composition-id of the tag:
Widgetic.show is there once the embed script has run. It returns true when the page has a pop-up for that id, and false when it has none, for example because the script has not found the composition yet. The rules and the view limits still apply, so a true is not a promise that the pop-up opened: listen for widgetic:overlay-blocked (below) to know why it did not.

Set the options with the API

The options of a composition are saved in its embedSettings, under the keys listed in Embed settings:
  • GET /compositions/{id}/schema/embed returns the schema of the options, which is the same for every composition, with the defaults of all of them.
  • GET /compositions/{id}/embed-settings returns what the composition saved. A composition that has saved nothing answers 404: start from the defaults of the schema.
  • PUT /compositions/{id} with embedSettings saves them. The object you send replaces the saved one, so send every setting you want to keep.
  • Send each value as the schema types it: a switch is true or false, a number is a number (8, not "8"). The opacity of a color is saved beside it, as overlayBackgroundColor_opacity, a number from 0 to 1.
  • Send only keys the schema lists. The gateway checks the object before it saves it: a key it does not know, or a value of the wrong kind, makes the call fail and nothing is saved. Read the schema rather than guessing a name.
  • The next new composition starts from them. The settings saved last on any composition of a widget are where a new composition of the same widget starts, unless you give it embedSettings of its own. A composition filed under a managed user is the exception: its settings stay with it, and no other composition starts from them.
  • Build the tag from the settings the way Compositions shows, or hand the job to an assistant: get_embed_settings and save_embed_settings read and save them, apply_embed_code copies them from a code you paste, and get_embed_code returns the standard JavaScript embed code (or an iframe, for a page that cannot run a script), plus a share link. See Embed settings in the MCP tools.

Use the npm package

If you bundle your own JavaScript (Vite, webpack, Next.js) and would rather not add a third-party script tag, the same code is on npm:
Load it in the browser only: it scans the page, and a server has no page. In React or Next.js, call it from an effect: import('@widgetic/embed-sdk').then(({ getSDK }) => getSDK()). The <widgetic> tag and its attributes are the same as above. For a page, a CMS or a template where you can add a <script> tag, the script from the CDN stays the supported way. It is published separately from the package, so it can be a different build from the version you installed.

Allowed domains

By default, a published widget can appear on any website. You can limit it:
  1. Dashboard: workspace Settings → Allowed domains (team workspaces: admins and owners only).
  2. API: GET and POST /organizations/{orgId}/domains, PUT and DELETE /organizations/{orgId}/domains/{domainId} (orgId is the id of the workspace) — see Domain validation and the matching widgetic api organizations … commands. The routes under /users/{id}/workspace/domains are gone.
localhost, Widgetic’s own sites and (for partners) your platform domain are always allowed. A page on another site gets 403 DOMAIN_NOT_ALLOWED; the embed script draws nothing and sets data-widgetic-refused="DOMAIN_NOT_ALLOWED". Partners can also set allowedDomains on the partner account; those domains are added to the allowed domains of your partner’s workspace, which is where your customers’ embeds are filed.

Events from the embed

The <widgetic> tag fires bubbling DOM events (same names as inside the iframe), including: Workflow embeds also fire widgetic:workflow-step. Send page events into a workflow with sendWorkflowEvent from @widgetic/embed-sdk or widgetic:workflow-event on the tag — see Embed a workflow. A pop-up or a floating box announces itself on document, with the id of the composition in detail.widgetId (a second tag for the same composition on the page gets -2 after the id, a third -3):

If the widget does not appear

Embed settings

Every option of the Embed code screen, with its key and its attribute

Embed a workflow

Show a path of compositions in one place, or in a frame

Compositions API

Create and publish compositions your embed points at

Security

Domains, keys in the browser and webhook signatures