Skip to content

TIGER-306: Matomo tracking adapter (first-party analytics + affiliate attribution) - #338

Merged
WebTigers merged 2 commits into
mainfrom
feat/tiger-306-matomo-tracking-adapter
Oct 14, 2026
Merged

WebTigers merged 2 commits into
mainfrom
feat/tiger-306-matomo-tracking-adapter

Conversation

@WebTigers

Copy link
Copy Markdown
Owner

TIGER-306 — the TigerAnalytics adapter

A new first-party matomo module — the config-selected tracking driver the ticket calls for, built as a sibling of analytics (GA4): same Tiger_Tracking registry shape, same consent gate, both can be active at once.

What it does

  • First-party tracking: Matomo_Plugin_Tag emits the self-hosted Matomo _paq snippet into the tigerTracking head placeholder, consent-gated (Tiger_Consent::allows('analytics')), staff-excludable, fail-open. Works standalone with zero affiliates.
  • Affiliate attribution: reads the /a/<name> contract cookie (tiger_aff), validates the name, and pushes a Matomo visit-scoped custom dimension before trackPageView — so visits + conversions segment by affiliate (the custom dim this populates is the one the TIGER-304 install created).
  • Admin Settings screen (/matomo/admin, admin-only) + /api save to the config tier (url, site id, affiliate dimension index, enabled, exclude-signed-in). 7 locales.

The module boundary (vs TIGER-303)

This module reads the affiliate cookie; TigerAffiliates (TIGER-303) writes it and owns the /a/<name> route. The cookie name/format is fixed here as the contract (Matomo_Plugin_Tag::AFFILIATE_COOKIE + AFFILIATE_NAME_RE) so 303 writes exactly what this reads. No route/cookie-write here = no dual-owner collision later.

Proof

  • 14 integration tests (plugin snippet/gating/affiliate-dimension-before-pageview/invalid-cookie/latch + controller view-vars). Full analytics+matomo suite green (46 tests).
  • Live on tiger-dev against the dev Matomo (analytics-dev.webtigers.com): guest pages emit the snippet (setSiteId '1', loader); tiger_aff=jane → setCustomDimension', 1, "jane" before the pageview; invalid cookie ignored; /matomo/admin gates to login; the admin .phtml renders (all i18n keys resolve, no fatals).
  • Caught + fixed an app-fatal bug the unit tests couldn't see: registering the front-controller plugin at stackIndex 92 (which analytics already owns) throws fatally during the module scan — now auto-assigned.

🤖 Generated with Claude Code

https://claude.ai/code/session_01ASauLLscjqdsNqBNsx2Typ

WebTigers and others added 2 commits October 14, 2026 06:55
…ics + affiliate attribution)

A new `matomo` module, sibling to `analytics` (GA4): a config-backed, consent-gated
self-hosted Matomo tracker that also reads the `/a/<name>` affiliate cookie into a Matomo
visit-scoped custom dimension so visits + conversions are segmentable by affiliate.

- Registers `matomo` in `Tiger_Tracking` (category analytics; coexists with ga4).
- `Matomo_Plugin_Tag` emits the `_paq` snippet into the `tigerTracking` head placeholder,
  gated by `Tiger_Consent::allows('analytics')`, staff-excludable, fail-open. Auto-assigns
  its front-controller stackIndex (analytics owns 92 — a duplicate index is fatal at boot).
- Affiliate: reads the `tiger_aff` contract cookie, validates the name, and pushes
  `setCustomDimension(<index>, <name>)` before trackPageView. This module READS the cookie;
  TigerAffiliates (TIGER-303) WRITES it and owns the `/a/<name>` route.
- Admin Settings screen (`/matomo/admin`, admin-only) + `/api` save to the config tier
  (url, site_id, affiliate dimension index, enabled, exclude-signed-in). 7 locales.
- Tests: 14 integration tests (plugin snippet/gating/affiliate-dimension/latch + controller).

Proven live on tiger-dev against the dev Matomo (analytics-dev.webtigers.com): guest pages
emit the snippet; `tiger_aff=jane` sets dimension 1 before the pageview; invalid cookie
ignored; admin route gates to login; admin view renders.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01ASauLLscjqdsNqBNsx2Typ
Adds the matomo module to the generated capability index (CI `check` gate).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01ASauLLscjqdsNqBNsx2Typ
@WebTigers
WebTigers merged commit 4b4f5dc into main Oct 14, 2026
14 checks passed
@WebTigers
WebTigers deleted the feat/tiger-306-matomo-tracking-adapter branch October 14, 2026 11:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant