Embedding
Get your embed snippet, choose a display mode and set options. Covers the script tag, Content-Security-Policy and using an iframe instead.
Embedding uses one script tag. You paste it into your site once, and every form you have set to embed shows up — you do not add a new snippet each time you build a form.
Getting your snippet
- Go to Console → Embed.
- If you have not made a key before, choose Generate embed key.
- Copy the snippet shown under Your embed snippet. It already has your key in it.
- Paste it into your site's HTML, before the closing
</body>tag.
The page can also show your active forms rendering, before you paste the snippet.
The snippet looks like this:
<script
src="https://js.poplitu.com/sdk/loader.min.js"
data-api-key="YOUR_EMBED_KEY"
async
></script>
The address is the same for everyone and does not change; only the key is yours. Copy the snippet from Console → Embed rather than typing this example, so the key is right.
It works on any site that lets you add HTML. For step-by-step instructions on WordPress, Shopify, Webflow, Wix, Squarespace, Google Tag Manager and React or Next.js, see Install on your platform.
How a form gets picked
The script asks Poplitu which of your forms should appear, and applies the targeting rules you set on each one — which pages it shows on, which devices, which countries and browser languages, what time, after how long, on exit intent, and how often the same person sees it. You set the basics in the Where & When step of the builder, and change them any time under Targeting rules in the menu on the form's card in the dashboard. The popup guide walks through it, and My popup is not showing helps when it does not appear.
Display modes
An embedded form can appear as a popup, a slide-in, a banner, a sidebar, or inline in the page.
Options
Add these to the script tag if you need them. Each is optional.
| Attribute | What it does |
|---|---|
data-overlay-close="false" | Stops a click outside the form from closing it. Clicking outside closes it by default. |
data-close-button="false" | Hides the close button. It shows by default. |
data-animation-ms="300" | How long the opening animation takes, in milliseconds. |
data-lock-scroll="true" | Stops the page behind an open popup from scrolling. |
data-disable-tracking="true" | Turns off visitor tracking for this page. |
To run your own code once the script has started, define a function named
poplituOnLoad on the page before the script loads:
<script>
window.poplituOnLoad = function () {
// the Poplitu script is ready
};
</script>
If your site has a Content-Security-Policy
A site that restricts which addresses it may load or contact needs to allow
https://js.poplitu.com (the script) and https://www.poplitu.com (where it
fetches your forms), for example script-src and connect-src entries for
both. Without them the browser blocks the script and nothing appears.
One script, once per page load
The script runs each time a full page loads. On a site that changes pages without reloading (a single-page app), the script loads once, when the first page loads: test that your forms appear where you expect as you move around.
Using an iframe instead
If you only want one specific form in one specific place, you can point an iframe at its public link. You lose targeting rules and the display modes, but it needs no key.
<iframe
src="https://www.poplitu.com/f/YOUR_FORM_ID"
width="100%"
height="600px"
frameborder="0"
></iframe>