Fix search-funnel analytics: report to Matomo via _paq + sendBeacon - #13038
Merged
Conversation
…eacon The search-modal and availability-toggle events added in internetarchive#12948 only ever reached Athena (via ol_send_event_ping), which does not forward into Matomo, so they never reported. Matomo normally ingests these via a tag-manager DOM trigger on data-ol-link-track, but that trigger can't see Shadow DOM (the Lit search modal / ol-toggle). Add a trackEvent() helper that pushes straight onto Matomo's _paq queue — the path the trigger ultimately uses — and route SearchModal._track and the SearchFilterBar toggle through it. Enable alwaysUseSendBeacon so events fired right before a navigation survive the page unload.
cdrini
approved these changes
Jun 25, 2026
cdrini
left a comment
Collaborator
There was a problem hiding this comment.
Lgtm! Can't really test this ; just confirmed the beacon appearing in the networks panel.
Co-authored-by: Drini Cami <cdrini@gmail.com>
This was referenced Aug 5, 2026
Closed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #13020
fix — The search-funnel events added in #12948 emitted but never landed in Matomo.
They were sent through
archive_analytics.ol_send_event_ping, which pings Athena — and Athena doesn't forward events into Matomo (confirmed by @scottbarnes on #13020). Matomo normally ingests OL events via a tag-manager DOM trigger ondata-ol-link-track, but that trigger can't see inside Shadow DOM, where the Lit search modal andol-togglelive. So these controls had no path into Matomo.Technical
trackEvent(category, action, label)helper inol.analytics.jspushes onto Matomo's_paqqueue directly — the same path the DOM trigger uses, so events report regardless of Shadow DOM.SearchModal._track()and theSearchFilterBartoggle route through it; the Athena ping is dropped.head.htmlnow pushes['alwaysUseSendBeacon'], so events that fire right before a navigation (result-click, "see all", toggle) are sent vianavigator.sendBeacon()and survive the page unload.Testing
With a Matomo-enabled environment, spy on the queue in DevTools:
const o = _paq.push.bind(_paq); _paq.push = (...a) => { console.log('PAQ', ...a); return o(...a); };['trackEvent', 'SearchModal', 'Open', 'click'].ResultClick / edition:3; "See all" →SeeAllResults / hasResults; no-results query →NoResults./search, toggle Readable Only →SearchFilter / AvailabilityOn|Off.Screenshot
No UI changes — analytics wiring only.
Stakeholders
@cdrini (Matomo admin; suggested the
_paqapproach on the issue)