Skip to main content
The Popup API lets you control any popup with code instead of relying only on the built-in triggers (page load, delay, scroll, exit intent). Call window.llPopupsApi from a Custom Code element or any script to open a popup from a button, close it after a form is submitted, or wire popups into your own integrations.
Use the popup’s ID, not its name. Everything in the API targets a popup by its id. The popup name (the human-readable label you see in the editor) is only metadata for analytics and display — it is never used for targeting. If you target by name, nothing will happen.

Step 1 — Prepare the popup

Before you can control a popup with code, set it up so it doesn’t fight your triggers, and give it an ID you can reference.
1

Set the trigger to Manual

In the Popup tab of the right sidebar, set the Trigger to Manual (button-only). The popup will never auto-open — it appears only when your link or script opens it.
You don’t have to use Manual. The API works on any popup regardless of its trigger. Manual just guarantees the popup stays closed until you open it yourself.
2

Give the popup an ID

The API targets popups by their id. Make sure your popup has a unique ID (for example promo-popup). This same ID is also what powers the Stay Dismissed and Show Once memory, so it’s worth setting.

The JavaScript API (window.llPopupsApi)

Call the global window.llPopupsApi object to open, close, or toggle a popup — on a custom event, after a delay you control, or from another script. Drop the code into a Custom Code element on your page.
// Open a specific popup
window.llPopupsApi.open('promo-popup');

Targeting: ID is optional

Every method takes an optional popup ID:
  • Pass an ID → the action affects that one popup.
  • Omit the ID → the action affects every popup on the page.
window.llPopupsApi.close('promo-popup'); // close one popup
window.llPopupsApi.close();              // close all popups on the page

Methods

MethodWhat it does
open(id?)Force-opens the popup. Reopens it even if the visitor dismissed it earlier in the session (your explicit call wins).
close(id?)Closes the popup with its animation. Does not set the “stay dismissed” cookie — the popup can be triggered again.
dismiss(id?)Closes the popup and locks it: sets the 30-day cookie if Stay Dismissed is on, or the session flag if Show Once is on. This is what the built-in close button does.
toggle(id?)Opens the popup if it’s closed, closes it if it’s open. (Opening via toggle force-opens, same as open.)
get(id?)Returns the popup’s HTML element when you pass an ID (or null if not found), or an array of all popup elements when you omit the ID.
close vs dismiss. close() is a temporary close — auto-triggers like exit-intent can still fire again. dismiss() is permanent for the session (and up to 30 days with Stay Dismissed). Use close() for “maybe later”, dismiss() for “don’t show this again”.

Examples

// Opens the popup when the visitor clicks your button
document
  .getElementById('my-button')
  .addEventListener('click', function () {
    window.llPopupsApi.open('promo-popup');
  });

Good to know

The API is ready after the page loads. window.llPopupsApi is created once the popup script runs. If you call it from inline code that runs immediately, wrap it in a DOMContentLoaded listener or place your script after the popup on the page.
  • Preview mode. On preview URLs, the “Stay Dismissed” cookie and “Show Once” flag are never read or written, so the popup always appears while you’re testing.
  • ESC to close. If Close on ESC is enabled for the popup, pressing Esc closes the topmost open popup — no code needed.
  • Open wins over dismissal. Calling open() reopens a popup even after a visitor dismissed it, but the popup’s own auto-triggers still respect the dismissal. Use dismiss() if you want to re-lock it.