# Popups

Popups reference: requirements, settings, 7 agent tools with full notes, and core events, read from the code.

Popups, slide-ins, top and bottom bars, welcome mats, inline offer boxes and floating tabs that match your site, collect signups through your existing forms, and show exactly when and to whom you choose, with results and A/B tests.

**Beta.** Popups is in beta: it works, but things may still break. If something breaks, [report it](https://github.com/sundoggs/support/issues/new).

On the store: [Popups](https://sundo.gs/apps/popups) in [Growth and conversion](https://sundo.gs/categories/growth), [pricing](https://sundo.gs/pricing).

## Price

$19 USD per site · $59 USD for all your sites, paid once. Every purchase includes 12 months of updates, and there is a full refund within 7 days. Details: [pricing](https://sundo.gs/pricing).

## Requirements

- Cloudflare® plan: Cloudflare free plan
- Works on: Cloudflare Workers; Cloudflare Pages; A site on its own server (VPS or cloud) with DNS on Cloudflare, through a Worker route in front of it (beta, tested on a live server) ([hosts](https://sundo.gs/docs/hosts.md))
- Version: 0.10.6 (needs core 0.21.0 or later; it comes in the same download)
- Runs on the Cloudflare free plan, in the same D1 database as your other site apps. No third-party script: popups are added to your pages as they're served.
- Signups go through Forms (the free Forms app, or the form engine that comes with every site app): they land in the same Inbox and contacts.
- Views and closes are counted in batches (about once a minute), within the site's daily write budget, so busy sites stay inside the Cloudflare free limits.
- Sets one small first-party cookie (\_sp) to remember which popups a visitor has seen, closed or signed up through, so they aren't shown again.
- Works with the Countdown Timers app when it's installed (timers inside popups and bars). Install order doesn't matter; removing either app never breaks the other.
- Cost per visit: no extra requests beyond one tiny beacon per popup action; views, closes and clicks are added up and saved about once a minute per popup. If the Cloudflare free limits are reached, counting pauses and popups keep showing. Visit sources are counted by core: page views are added up in memory and saved in a few small writes about every 20 seconds, within the daily write budget; at the Cloudflare free limits counting pauses and the site is unaffected.

## What it adds to the site

- Addresses it answers: `/_sp/*`
- Edits pages as they are served: yes
- Has a say when a page is not found: no
- Uses the site's [brand](https://sundo.gs/docs/core.md#brand): yes
- [Core](https://sundo.gs/docs/core.md) capabilities it uses: `forms`
- Database tables (in the site's own D1 database): `popups_popups`, `popups_daily`

### Cookies and browser storage

What the app sets in a visitor's browser. Anything that is not necessary waits for [consent](https://sundo.gs/docs/core.md#consent).

| Name | Category | Kept in | Lasts | What it is for |
|---|---|---|---|---|
| `_sp` | preferences | cookie | 1 year | Remembers which pop-ups a visitor has already seen, closed or signed up through (and which version of a test they got), so they aren't shown again too soon. (only on pages that have a pop-up, and only if preferences are allowed (otherwise \_sps is used for the visit)) |
| `_sps` | necessary | cookie | session | When preferences aren't allowed: remembers, for this visit only, which pop-ups were shown or closed so a closed pop-up doesn't come back on every page. No identifier, no test version, deleted when the browser closes. (only on pages that have a pop-up, only if preferences are not allowed) |
| `sp_pv` | preferences | sessionStorage | until the tab closes | Counts the pages viewed in this visit, for pop-ups that appear after a number of pages. (only on pages that have a pop-up, and only if preferences are allowed) |
| `sp_s_*` | preferences | sessionStorage | until the tab closes | Notes that a pop-up was already shown in this visit, for pop-ups limited to once per visit. (only on pages that have a pop-up, and only if preferences are allowed) |

## Agent tools

Popups adds 7 tools to the site's own [agent connection](https://sundo.gs/docs/agent-connection.md). The short text under each name is what an agent sees in its tool list; the full notes are what `site_tool_help` returns. The [shared rules](https://sundo.gs/docs/core/site-tools.md#shared-rules) for `confirm`, `dry_run` and `on` apply to every tool.

### Read (changes nothing)

#### `popups_list`

Start here before changing a popup. The site's popups with status, type, trigger, targeting and 30 days of results. `stillTemplateText` (template sample text: going live needs confirm:true) and `warnings` (with the fix) flag popups that won't work as meant. Popups wait for the cookie banner's answer; there is no 'only after consent' switch (site_tool_help says what to offer instead).

Read only: changes nothing.

**Full notes** (what `site_tool_help` returns):

stillTemplateText lists the template's sample text a popup still holds (a coupon code, "10% off" copy, /guide.pdf). warnings: its form was deleted or is a draft, its timer has ended and hides it, its button goes to a /go/ link that leads nowhere, or its signups have no inbox to land in. Popups wait until the cookie banner has been answered, whatever the answer is. Showing a popup is not tracking, and a popup's own cookies already follow the visitor's preferences choice, so there is no 'only after consent' switch. If the owner asks for that, say so plainly and offer the frequency settings (how often it shows, stop after a close or a signup) and the trigger settings (a delay, scroll depth, exit intent, time on the page) instead.

| Field | Type | Required | What it is |
|---|---|---|---|
| `status` | `"draft"`, `"live"`, `"paused"` | no | Only popups with this status. |

#### `popups_get`

One popup in full, as popups_save takes it, plus whereFrom (top three sources of its conversions in 30 days) and `warnings` with the fix when something stops it working as meant.

Read only: changes nothing.

**Full notes** (what `site_tool_help` returns):

Full: content, trigger, targeting, frequency, A/B version. whereFrom has the same figures as the admin's Where from card. warnings: its form was deleted or is a draft, its timer ended and hides it, its button goes to a /go/ link that leads nowhere, signups have no inbox. Popups wait until the cookie banner has been answered, whatever the answer is. Showing a popup is not tracking, and a popup's own cookies already follow the visitor's preferences choice, so there is no 'only after consent' switch. If the owner asks for that, say so plainly and offer the frequency settings (how often it shows, stop after a close or a signup) and the trigger settings (a delay, scroll depth, exit intent, time on the page) instead.

| Field | Type | Required | What it is |
|---|---|---|---|
| `id` | integer | no |  |
| `name` | string | no |  |

#### `popups_templates`

The ready-made popups popups_create_from_template can create, with what each requires, what it leaves blank, and `sampleText` (fields that need confirm:true to go live unchanged).

Read only: changes nothing.

**Full notes** (what `site_tool_help` returns):

For example newsletter signup, exit offer, discount. Fill in what a template leaves blank with popups_save afterwards. sampleText: the fields that hold template text until you change them.

Takes no input.

### Change

#### `popups_create_from_template`

Create a draft popup from a template (see popups_templates). Templates with a form use the site's 'newsletter' form (created if missing), or the existing form you name in `form`. Adjust it with popups_save, preview it, then set it live.

Changes the site.

**Full notes** (what `site_tool_help` returns):

form (optional): the name or id of a form already on the site (forms_list), for templates with a signup form; the popup collects into it instead of 'newsletter'. If no form has that name or id, nothing is created and the answer lists the site's forms. Templates without a form (discount, announcement, ask-review) refuse it. Left out: the template uses the 'newsletter' form, and creates it (live, not yet reviewed by the owner) when the site has none. The answer says which form the popup uses and whether it is a draft.

| Field | Type | Required | What it is |
|---|---|---|---|
| `template` | string | yes | Template id from popups_templates. |
| `form` | string | no | Optional: name or id of an existing form to use instead of 'newsletter' (forms_list). |

#### `popups_toggle`

Switch a popup between live and paused (live within about 15 seconds). Turning on one with template sample text or an unreviewed form needs confirm:true. Without `on` it flips, which is not safe to retry. Risky input (the answer says which) does nothing until called again with confirm:true.

Changes the site.

**Full notes** (what `site_tool_help` returns):

Sample text is a placeholder code or "10% off" copy; the answer lists what is unchanged.

| Field | Type | Required | What it is |
|---|---|---|---|
| `id` | integer | no |  |
| `name` | string | no | The name, as in the matching get tool. Use this or id. |
| `on` | boolean | no | true: on, false: off. Sets the state (safe to retry). |
| `confirm` | boolean | no | true only after an answer asked for it, with confirm_token. |
| `confirm_token` | string | no | The answer's confirmToken, sent with confirm:true and the same input. |

#### `popups_save`

Create a popup (name and content; starts as draft) or change one (id plus only the parts to change: PATCH, also inside content, trigger, targeting and frequency). Going live with template sample text or an unreviewed form needs confirm:true. Read the answer's warnings and fix them or tell the owner. Popups wait for the cookie banner's answer; there is no 'only after consent' switch (site_tool_help says what to offer instead). Risky input (the answer says which) does nothing until called again with confirm:true.

Changes the site.

**Full notes** (what `site_tool_help` returns):

Or use popups_create_from_template. PATCH: omitted fields, and omitted keys inside content, trigger, targeting and frequency, keep their saved values; read them with popups_get. The warnings say if its form doesn't exist or is a draft (the popup then shows nothing), a timer is missing, or the setup goes against Google's guidance on mobile popups. A popup with a form needs that form to exist and be live in Forms. position depends on type: modal and fullscreen: center. slidein and tab: right or left. bar: top or bottom. inline: main-end, after-h1, main-start or before-footer. Omitted: the first one for the type. Popups wait until the cookie banner has been answered, whatever the answer is. Showing a popup is not tracking, and a popup's own cookies already follow the visitor's preferences choice, so there is no 'only after consent' switch. If the owner asks for that, say so plainly and offer the frequency settings (how often it shows, stop after a close or a signup) and the trigger settings (a delay, scroll depth, exit intent, time on the page) instead.

| Field | Type | Required | What it is |
|---|---|---|---|
| `id` | integer | no | To change a popup. Leave out to create one. |
| `name` | string | no | Short name: lowercase letters, digits and dashes (becomes #popup-\<name\>). Needed when creating. |
| `title` | string | no | Label for the owner in the admin list. |
| `status` | `"draft"`, `"live"`, `"paused"` | no | New popups should start as draft; set live when the owner is happy. |
| `type` | `"modal"`, `"slidein"`, `"bar"`, `"fullscreen"`, `"inline"`, `"tab"` | no | modal (middle), slidein (bottom corner, best on mobile), bar (top/bottom strip), fullscreen (welcome mat, desktop), inline (inside the page), tab (side tab). |
| `position` | `"center"`, `"right"`, `"left"`, `"top"`, `"bottom"`, `"main-end"`, `"after-h1"`, `"main-start"`, `"before-footer"` | no | One of the values listed; which ones fit depends on type (site_tool_help). Omitted: the first for the type. |
| `content` | object | no | What it says and does; send only the keys to change. EITHER form (a live form's short name) OR button. step1 asks yes/no first (null turns it off). countdown: a timer's name. |
| `trigger` | object | no | When it appears. on: load\|delay\|scroll\|exit\|inactivity\|pages\|click; seconds, mobileSeconds (for delay), percent (scroll), pages (pages viewed). Wait for engagement with minPercent, minSeconds and match (all\|any). |
| `targeting` | object | no | Who sees it. include / exclude: path patterns like /blog/\* (empty include = every page); countries: two-letter codes; param like "utm_source=newsletter". |
| `frequency` | object | no | How often: every (page\|session\|days), days, maxCloses (stop after closed N times; 0 = never), stopAfterSignup. |
| `variantB` | object | no | {headline, text, buttonLabel, question} runs an A/B test (half the visitors see each version). abTest:false removes it. |
| `abTest` | boolean | no | false stops the A/B test (removes variantB). Old "0" still works. |
| `priority` | integer | no | Lower shows first when several popups match. |
| `startsAt` | string | no | Start date (UTC, e.g. 2026-12-01). Empty string clears it. |
| `endsAt` | string | no | End date (UTC). Empty string clears it. |
| `confirm` | boolean | no | true only after an answer asked for it, with confirm_token. |
| `confirm_token` | string | no | The answer's confirmToken, sent with confirm:true and the same input. |
| `dry_run` | boolean | no | true: save nothing; answers wouldSave (the full record) and the warnings. |

#### `popups_delete`

Delete a popup and its results permanently. DESTRUCTIVE: does nothing until called again with confirm:true.

Changes the site. Destructive: does nothing until it is called again with `confirm`.

| Field | Type | Required | What it is |
|---|---|---|---|
| `id` | integer | no |  |
| `name` | string | no | The name, as in the matching get tool. Use this or id. |
| `confirm` | boolean | no | Leave out first (the answer says what would happen); then true, with confirm_token. |
| `confirm_token` | string | no | The answer's confirmToken, sent with confirm:true and the same input. |

## Core events

- Reports as conversions: `popups.converted` (Popup converted)
- Counts as actions: `popups.shown` (Popup shown)

How events work: [core events](https://sundo.gs/docs/core.md#events).

## Works with your other apps

Connects with no setup, in any install order: [Forms](https://sundo.gs/docs/apps/forms.md), [Countdown Timers](https://sundo.gs/docs/apps/countdown.md), [Analytics](https://sundo.gs/docs/apps/analytics.md), [Cookie Consent](https://sundo.gs/docs/apps/consent.md).

---

This page on the web: https://sundo.gs/docs/apps/popups/
