Preserve Intent analytics undercount: Dismiss has no Matomo path, and the banner only renders on the fallback login path
Summary
Investigating why Preserve Intent stats look low (a handful of events/day). There are two independent causes — one a real wiring regression, one by-design flow behaviour that makes the metric structurally blind to the success path. Ad-blockers are not the main story.
1. PreserveIntent|Dismiss has no path into Matomo at all (regression, 2026-07-17)
- #12849 originally set
data-ol-link-track="PreserveIntent|Dismiss"on the dismiss control inopenlibrary/templates/account/view.html. - #12910 (
e6008625f, 2026-07-17) migrated the banner to<ol-banner>and removed that attribute, replacing it withbanner-analytics.js→window.archive_analytics.ol_send_event_ping(). - Per #13038 / #13020 (confirmed by @scottbarnes): Athena does not forward events into Matomo. Matomo ingests OL events via the MTM DOM trigger on
data-ol-link-track. - The
<ol-banner>close button (OlBanner.render()) carries nodata-ol-link-track, so that trigger has nothing to match.
⇒ Expect exactly 0 PreserveIntent|Dismiss in Matomo since 2026-07-17, regardless of real usage.
Worth noting the timing: #12910 merged three weeks after #13038 established the Athena/Matomo split, and this is the same bug class as the 2026-08-04 dialog.js fix (4e9a1e02e, "resolve missing Matomo events for Book Preview and Search Inside"). This keeps recurring because ol_send_event_ping still looks like the house style for event tracking.
2. PreserveIntent|Continue only fires on the fallback path — the happy path never renders a banner
openlibrary/plugins/upstream/account.py (~617–625):
if not is_safe_redirect(redirect) or any(path in redirect for path in blacklist):
redirect = "/account/books" # cookie KEPT → banner renders
else:
web.setcookie("pending_action", "", expires=-1) # cookie CLEARED → straight to the action
stats.increment("ol.account.xauth.login")
raise web.seeother(redirect)
- When the redirect is safe — the normal case, since
js/index.jssends patrons to/account/login?redirect=<targetUrl>— the cookie is cleared and the patron is sent directly to their intended action. No banner renders, so no event can fire. Every successful preserve-intent resumption is structurally invisible to this metric. - The banner only appears when the redirect is empty, unsafe, or blacklisted. Blacklist is
/account/login,/account/create,/account/verify. - ⇒ The dominant producer of banner impressions is the register → verify-email flow, because
/account/verifyis blacklisted — not ordinary login. That is entirely consistent with a small, steady handful per day. - The FastAPI twin (
openlibrary/fastapi/account.py~236–280) has the same branch but falls back to/rather than/account/books.account/view.htmlis not rendered at/, so that path produces no banner at all. - Cookie TTL is 36h (
max-age=129600,queueActioninjs/utils.js) — intent older than that is silently dropped. - The trigger surface is only 6 templates carrying
.js-login-intent(ReadButton,LoanStatus,StarRatings,follow,primary_action,modal_links).
This is the direct answer to "why does it trigger only sometimes?" — the counter only increments on the degraded path, and only for patrons who then click Continue.
3. Secondary: no sendBeacon, so navigation-time events are lossy
- #13038's description states head.html pushes
['alwaysUseSendBeacon']. It does not.alwaysUseSendBeaconappears nowhere onorigin/master, andgit log -Sshows it was never added tohead.html. Either it was dropped in review or lost in a later edit to that block. PreserveIntent|Continueis a navigating<a href>, so its event fires immediately before unload. WithoutalwaysUseSendBeacon, a share is lost. This affects every navigation-adjacent Matomo event, not just this feature.
What is not the main cause
Ad-blockers and tracking protection do suppress some client-side beacons, but they cannot explain this: Dismiss is structurally zero, and Continue is bounded by the small fallback-path population before any blocking is applied.
Falsifiable prediction (needs Matomo admin to confirm)
Behaviour → Events, site 6 (openlibrary.org), last 30 days:
PreserveIntent / Dismiss≈ 0PreserveIntent / Continuesmall but non-zero (roughly the observed handful/day)
If Dismiss is 0 while Continue is non-zero, causes 1 and 2 are confirmed.
Explicitly not verified
- No measured Matomo counts in this report.
matomo.archive.orgis IP-restricted and no proxy/VPN gateway was available from this environment, so everything above is derived from code onorigin/master, not from production data. The numbers still need admin-side confirmation. - MTM container config is server-side. "The MTM trigger keys on
data-ol-link-track" is taken from #13038/#13020, not something readable from the repo. - There is no server-side ground truth for this path.
stats.increment("ol.account.xauth.login")sits after the if/else and fires on every xauth login, so it cannot measure pending-action resumptions. Worth knowing before anyone tries to use it as a denominator.
Suggested follow-ups (investigation only — nothing changed here)
- Restore a Matomo path for Dismiss — either re-add
data-ol-link-track, or routebanner-analytics.jsthroughtrackEvent()(_paq) instead ofol_send_event_ping. - Add
_paq.push(['alwaysUseSendBeacon'])tohead.html(fixes a whole class of pre-navigation event loss). - Add a server-side counter on both
pending_actionbranches, so "intent preserved" is measurable independently of client-side analytics. This is the only way to ever see the happy path, which is currently 100% invisible. - Decide whether FastAPI's
/fallback should match legacy's/account/books.
Given how often ol_send_event_ping has now silently failed to reach Matomo (#13038, 4e9a1e02e, and this), it may be worth a lint rule or a deprecation comment on it.
cc @Sadashii — you authored #12764 / #12849 / #12910 and the 2026-08-04 Preview/SearchInside Matomo fix, so this is squarely your area. (Note: commits author as "Tanishq Sangwan" but the GitHub account is @Sadashii — same person, one ping, not two.) cc @cdrini (Matomo admin — items 1 and 2, plus the prediction check above) cc @scottbarnes (you confirmed the Athena→Matomo split on #13020)
Refs: #9409 · #12764 · #12849 · #12910 · #13095 · #13038 · #13020
Validation plan — fixing cause 1 (the Dismiss regression)
Scoping this PR to cause 1 only: restore a Matomo path for banner dismissals. That is the actual regression and it stands on its own. Causes 2 and 3 are handled below.
Approach
Route banner-analytics.js through trackEvent() (window._paq) instead of archive_analytics.ol_send_event_ping() (Athena). This is exactly the fix #13038 established for the search funnel, so it is a precedent-following change rather than a new pattern.
Worth noting this fixes both entries in BANNER_EVENTS, not just Preserve Intent:
| Banner id | Event | Status in Matomo today |
|---|---|---|
pending-action-container |
PreserveIntent | Dismiss |
0 since 2026-07-17 (#12910) |
book-unavailable-banner |
OpenRelatedBooks | Dismiss |
0 since it shipped (#12910/#12743) |
OpenRelatedBooks|Dismiss has never reported — it was written against the Athena helper from the start. So this is a general fix to the shared banner path, which is also why it is worth doing here rather than patching one call site.
Files
openlibrary/plugins/openlibrary/js/banner-analytics.js— swap the Athena ping fortrackEvent().tests/unit/js/bannerAnalytics.test.js— new; there is no test coverage for this module today, which is precisely how the regression went unnoticed.
Tests (input → expected)
Following the jest.mock pattern already used in tests/unit/js/sortOptions.test.js:
- Dismiss
pending-action-container(id one.target, nodismiss-id) →trackEvent('PreserveIntent', 'Dismiss')called once. - Dismiss
book-unavailable-banner→trackEvent('OpenRelatedBooks', 'Dismiss')called once. dismiss-idattribute present and taking precedence overid→ still resolves to the right event.- Unknown banner id →
trackEventnot called. - No id at all →
trackEventnot called, no throw.
A regression test pinning "the event reaches the Matomo path" is the real deliverable here — the mechanism has now silently broken three times (#13038, this, 4e9a1e02e).
Success criteria
- Automated: the five cases above pass under
npx jest tests/unit/js/bannerAnalytics.test.js; full JS suite stays green; pre-commit clean. - Manual (browser, in Docker): force a
pending_actioncookie, load/account/books, patch_paq.pushper #13038's recipe, dismiss the banner, and confirm a['trackEvent', 'PreserveIntent', 'Dismiss']push. Console clean.
Out of scope (deliberately)
- Server-side
pending_actioncounters (cause 2) — this is the only thing that would make the success path measurable at all, and it is the more valuable change, but it touches two auth handlers (plugins/upstream/account.pyandfastapi/account.py) and needs its own tests. Mixing server-side auth instrumentation into a client-side analytics fix would widen the blast radius and make review harder. Follow-up. - FastAPI
/vs/account/booksfallback — a behavioural change that needs a product decision, not a bug fix. alwaysUseSendBeacon— see the correction below.
Correction to cause 3 in the issue above
I overstated this. alwaysUseSendBeacon is absent from the repo — that part is verified — but I implied its absence necessarily means events are being lost. It does not: the Matomo JS tracker has had alwaysUseSendBeacon on by default since Matomo 4, so on any modern tracker the missing push is a no-op rather than a defect, and #13038's claim to have added it was simply inaccurate about the file, not about the outcome.
I am therefore not shipping that line. It needs @cdrini to confirm the tracker's major version first: if the instance is Matomo 4+, there is nothing to fix and the item should be dropped; only if it is on 3.x does it become a real (and separate) fix. Flagging rather than quietly adding a line that may do nothing.
Risk
Dropping the Athena ping means these two dismissals stop appearing in Athena. #13038 made the same trade deliberately ("the Athena ping is dropped") so this stays consistent with the house pattern, but calling it out explicitly in case Athena continuity matters to anyone for these specific events — easy to send both if so.
Cause 3 resolved and withdrawn; the _paq path is confirmed
Production data from Mek closes out both loose ends from this investigation.
Cause 3 (alwaysUseSendBeacon) — withdrawn. The instance is Matomo 5.11.2, and this setting has been default-on since Matomo 4. Its absence from head.html is a genuine no-op, so there is no event loss and no fix required. My original framing of it as lost events was wrong; #13038's description was inaccurate about the file, but nothing was actually lost. Please disregard that item.
The fix's one unverified assumption is now verified. Behaviour → Events shows SearchModal at 9,325 events (Open 3,076 · ResultsShown 2,658 · SeeAllResults 1,730 · ResultClick 1,076 · NoResults 785). Those are the events #13038 rewired, and they can only have arrived via _paq — SearchModal is a Shadow DOM Lit component, which is precisely why the data-ol-link-track DOM trigger could not see it. So trackEvent() → _paq → Matomo demonstrably works in production, which is the mechanism #13264 uses.
Worth noting this had never actually been confirmed before: this issue's sibling #13020 was auto-closed one second after #13038 merged (by its Closes line), not by the admin-side check that PR requested. Three PRs were relying on an unconfirmed pattern. It is confirmed now.
It also answers the ad-blocker question quantitatively: 9,325 events get through, so privacy tooling is a partial discount, not a suppressor. PreserveIntent|Dismiss at 0 against that baseline is absence, not low usage — exactly as cause 1 predicted.
Causes 1 and 2 stand unchanged. #13264 fixes cause 1. Cause 2 (the metric being blind to its own success path) is untouched and still the more valuable fix.
Mechanism confirmed against the live MTM container — diagnosis holds
Mek checked the Matomo Tag Manager container. The relevant contents:
| Type | Name |
|---|---|
| Trigger | Data_OL_Link_Track |
| Tag | OL_Data_Link_Tracker |
| Variables | OL_EventCategory, OL_EventAction, OL_EventName |
The two paths are independent — Athena does not forward to Matomo. A click on a data-ol-link-track element is read by two systems that don't feed each other:
click on [data-ol-link-track="Category|Action|Label"]
├─→ OL's jQuery handler (ol.analytics.js) → ol_send_event_ping → athena.archive.org/0.gif
└─→ MTM trigger Data_OL_Link_Track → tag OL_Data_Link_Tracker → Matomo event
So both statements are true simultaneously, which is what made this confusing: there is no Athena→Matomo pipeline (@scottbarnes was correct on #13020), and attribute-tagged events do reach Matomo, because MTM watches the same clicks independently.
This confirms the asymmetry in the original report
data-ol-link-track? |
MTM can match it? | In Matomo | |
|---|---|---|---|
Continue |
Yes — verified live on production as "PreserveIntent|Continue" |
Yes | Reports |
Dismiss |
No — removed by #12910 | No | Zero |
.ol-banner__close is a Lit-rendered button with no tracking attribute, so Data_OL_Link_Track has nothing to match, and banner-analytics.js only pinged Athena. #13264's reroute through _paq is the correct fix — the same route as the seven categories already reporting.
⚠️ Testing trap worth knowing: Matomo honours DNT, Athena does not
During manual verification on production with DNT: 1 set, clicking Continue produced a visible athena.archive.org/0.gif request and no Matomo request at all. I briefly misread that as the MTM trigger being absent. It wasn't — the Matomo Configuration variable respects Do-Not-Track while Athena ignores it.
Before concluding a Matomo event is missing from a network capture, check for dnt: 1 in the request headers. Verify against Matomo's Events report rather than the network tab, or test with DNT off.
Retraction
I earlier stated flatly that "Athena does not forward into Matomo" as though it settled where OL events come from, sourced from a code comment and a hedged remark ("to my knowledge there is no current way…"). The no-pipeline part was right, but I presented it as the whole picture when the MTM trigger was the missing half. The container config above is the authoritative answer and is now documented in ol-kb/wiki/analytics-events.md so this doesn't have to be rediscovered.
Closed by @cdrini's work on #13300