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.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.
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.
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.
Methods
| Method | What 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
Good to know
- 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. Usedismiss()if you want to re-lock it.