Every WordPress site I audit carries the same three scripts at the bottom of the page: a chat widget, a
heatmap, and a popup tool. All three are hosted elsewhere, all three block on a third-party connection,
and at least one bills the owner by pageview. I wanted to know what a popup plugin looks like when you
refuse those defaults, so I built one. This is the architecture write-up: the constraints, the code, and
where the trade-offs actually hurt.
1. The hidden cost of SaaS popup scripts in WordPress
A SaaS popup tool is a multi-tenant service. Every customer's popup is served from a CDN edge, and every
impression is recorded somewhere so the dashboard can show a funnel and the billing can count pageviews.
That means a global CDN, an ingestion pipeline, a per-customer analytics store and support for all of it.
So the vendor's cost scales with your traffic — and that one fact explains most of the annoying
properties of the category:
- Third-party scripts on every page. The popup markup and logic live on the vendor's domain, so the browser needs a DNS lookup, a TLS handshake and a script download from a host you do not control. On a 3G connection this is often the difference between an INP under 200 ms and one well over it.
- Impressions as the billing meter. Once you count impressions server-side, "pageviews" becomes the natural unit for a price list, and every plan gains a ceiling: 2,500 impressions a month, 10,000 visitors, 25,000 pageviews. Traffic growth becomes a bill increase, and the vendor's marginal cost becomes your marginal cost.
- Renewal as a second price list. The first-year discount is not generosity. It buys a year of data lock-in, and the renewal row is where the real price sits — which is why renewal prices in this category routinely run 1.5–2.5× the introductory one.
- Data leaving the site. If the vendor counts impressions, the visitor's browser talks to the vendor. Now you have a processor, a DPA, a cookie banner question, and a GDPR surface you did not want.
None of that is malicious. It is what the architecture costs. The interesting question is what you can
delete if you refuse it.
2. Aggregated local stats without bloating wp_options or storing visitor PII
The first thing to delete is the event stream. You do not need one event row per impression. You need
counters.
The stats table is:
CREATE TABLE wp_pophonest_stats (
id bigint(20) unsigned NOT NULL AUTO_INCREMENT,
campaign_id bigint(20) unsigned NOT NULL,
stat_date date NOT NULL,
views bigint(20) unsigned NOT NULL DEFAULT 0,
submits bigint(20) unsigned NOT NULL DEFAULT 0,
clicks bigint(20) unsigned NOT NULL DEFAULT 0,
PRIMARY KEY (id),
UNIQUE KEY campaign_date (campaign_id, stat_date),
KEY stat_date (stat_date)
);
One row per campaign per day. Every view, click and submit is a single statement against that row:
INSERT INTO wp_pophonest_stats (campaign_id, stat_date, views, submits, clicks)
VALUES (%d, %s, %d, %d, %d)
ON DUPLICATE KEY UPDATE views = views + 1;
Three consequences worth spelling out:
The table has a ceiling. 100 campaigns × 365 days is about 36,500 rows a year, whether the site serves
10,000 or 10,000,000 pageviews. A log-per-view design grows linearly with traffic — exactly how
"lightweight analytics" becomes a 200 MB table and a slow admin screen on a busy site.
Reporting is a SUM(). Daily and per-campaign totals plus the two rates (submits/views,
clicks/views) are aggregate queries over a date range with an index on stat_date — fast for years
without pre-computation.
There is no PII in it. No IP, no URL, no referrer, no user agent, no session id. A stats row cannot be
tied to a person even in principle. That matters more than the storage saving: it means this table never
enters a GDPR conversation.
The trade-off: the stats table cannot answer "which URL converted best yesterday" — the leads table can,
because it stores page_url per captured lead. Small-and-anonymous beat queryable-per-visit, because
per-visit queryability is what makes a pageview bill possible in the first place.
Schema changes without a migration script. WordPress has dbDelta(), which only adds what is missing.
So adding the clicks column in 0.3.0 needed no migration: compare the stored pophonest_db_version
option against the code constant, and when they differ run install_schema() and write the new version
back. Existing rows keep their values, the new column defaults to 0, no table lock, no re-import. The
only discipline is remembering to bump the constant.
3. 11.2 KB gzipped and page-cache safe (WP Rocket / LiteSpeed / Cloudflare APO)
Front-end payload, gzip over the wire:
| Asset | Raw | Gzip |
|---|---|---|
pophonest.js |
24,172 B | 7,135 B |
pophonest.css |
8,836 B | 2,451 B |
templates.css |
7,601 B | 1,661 B |
| total | 40,609 B | 11,247 B |
No jQuery, no dependency array, no remote fonts, no icon font — the script is enqueued in the footer with
array() as its dependency list. On the wire there are zero external requests: the only calls the browser
makes are to the site's own REST routes.
Nothing loads unless a campaign can match. should_load_assets() returns true only when an active
campaign matches the current request, or when the post content contains the [pophonest_inline]
shortcode. A page with no matching campaign has no PopHonest request in the network panel at all — 0
bytes, not "small bytes". A shortcode placed outside the main content (widget, block template) is caught
by a fallback enqueue pass so inline forms still render.
The page-cache problem is the interesting part. A full-page cache serves one HTML document to every
visitor, so any rule of the form "show this only on mobile" or "hide this from returning visitors" is
wrong for most visitors if it is decided in PHP — and a cache-poisoning risk if you try to vary output.
So targeting is split in two:
- Server-side, cache-safe: campaign status, page/post targeting, schedule windows, shortcode placement. These produce identical output for every visitor of a given URL, so caching them is correct.
-
Deferred to the client: viewport class (
<768pxmobile,<1024pxtablet, otherwise desktop) and the new-vs-returning flag. These are evaluated in JavaScript after load.
The returning-visitor flag is a first-party cookie set on first display, read at the top of the script
before anything writes to it, so the current page view cannot corrupt the answer.
Storage falls back three ways: localStorage → first-party cookie → in-memory. The in-memory tier is the
one that matters. In private browsing or with storage-blocking extensions, the reasonable behaviour is
"the frequency cap applies only within this page view", not a thrown exception and a dead popup.
The result: one cached document is correct for every visitor, and a device-rule change never needs a cache
purge. The cost is a few hundred bytes of client-side work — cheaper than a cache miss.
4. Local anti-spam and minimal GDPR without loading reCAPTCHA
A lead form with no protection gets spam within days. reCAPTCHA fixes it by adding another third-party
script to the page we just spent this entire design removing, so the endpoint has four local layers
instead:
-
Honeypot. A hidden field (
ph_website) is rendered but invisible. If it arrives non-empty, the request gets a success response and nothing is written. - Minimum fill time. A submission claiming to be completed in under 1200 ms is treated as a bot and silently discarded (filterable).
- Rate limiting. Fixed-window transient counters keyed by a hash of the client address: 60 views/min, 30 clicks/min, 10 leads per 10 minutes.
- De-duplication. The same email submitting to the same campaign within 24 hours is accepted but stored once.
Layers 1 and 2 return a normal success payload. That matters: a bot that gets an error learns which
layer caught it and retries with a patched payload. A bot that gets "thanks, we saved your email" has no
signal to iterate on.
Consent is enforced server-side, not just rendered as a checkbox: if a campaign enables the consent field,
the REST endpoint rejects a submission without consent: true, and the lead row records the consent
timestamp and the label text the visitor agreed to. Deleting a single lead from the admin screen deletes
the row; there is no second copy.
The REMOTE_ADDR trade-off, honestly. The address used for hashing and rate-limit keys is
$_SERVER['REMOTE_ADDR']; X-Forwarded-For is not trusted. On normal hosting that is the real client
address. Behind a CDN or proxy that leaves REMOTE_ADDR as the edge node, every visitor shares one
rate-limit bucket — stricter than intended, and able to make a busy site hit the global per-IP lead
limit. The fix is a small filter or proxy configuration. The alternative is worse: trusting a
client-supplied header lets a spammer rotate a fake IP per request and bypass the rate limit and dedupe
hash entirely. Deduplication is unaffected, since it keys on email + campaign.
The stored value is wp_hash() of the address, never the address itself — the same hash doubles as the
rate-limit key, so raw IPs never reach the database.
5. How local-only architecture makes flat renewal pricing possible
Here is the part that is architecture, not marketing.
If the site's own server renders the popup, increments a counter row and filters its own spam, the plugin
author's marginal cost per impression is zero: no CDN egress to bill, no event pipeline to scale, no
per-tenant analytics store to grow. A plugin that never sees your traffic has no reason to charge for it —
and no mechanism to measure it, which is the stronger point.
That is why flat pricing is structurally available here and structurally awkward for a SaaS: not because
one vendor is friendlier, but because one of them has nothing to meter. Where a plan has no traffic meter,
there is also no renewal trap to fall into: the renewal row can be printed on the pricing page before
purchase and honoured, because the unit being sold is a licence, not a volume.
Two honest limits. You lose the features that require a server: hosted A/B reporting across many sites,
cross-site benchmarks, remote licence revocation. And "local-only" is a property you must keep verifying,
not a one-time claim — one CDN call added in a later release voids the whole argument.
If you are auditing popup tools for a client, the useful question is not "which has more features" but
"where does the meter sit, and what does the renewal row say". Everything here is downstream of those two
lines.
Disclosure: I build PopHonest, the plugin described here. The details and byte counts above come from the
0.3.0 release.
References & Further Reading
- PopHonest on WordPress.org (free plugin, GPLv2): https://wordpress.org/plugins/pophonest/
- Installation and setup walkthrough: https://pophonest.com/how-to-install-pophonest/
- The tools that bill by pageviews or impressions, and what each tier costs: https://pophonest.com/popup-plugins-that-charge-by-pageviews/
- OptinMonster alternatives compared by year-two cost: https://pophonest.com/alternatives/optinmonster/
Top comments (0)