What this layer controls
- Which traffic source, campaign and creative produced a session or an order
- Whether a conversion counted once, twice, or not at all
- How a channel is credited when a customer touches three of them
- The retention window and export path for your own history
- The definition of every event the rest of the business argues about
What it looks like when it is wrong
These are the symptoms that show up in a marketing report or a Monday meeting. Each one has a technical cause in this layer, and each is cheaper to fix before it has a quarter of history behind it.
- Two dashboards disagree about the same month and nobody can say which is right
- Ad platforms claim three times the conversions your own site recorded
- A rename or a tag change silently orphaned two years of history
- Consent blocks fire after the tag, so the audit trail proves the opposite of the intent
- Nobody can answer ‘what did this campaign return’ without a spreadsheet
An open-source stack for this layer
Every project below is open source and self-hostable, with the licence the project publishes today. This is a reference build, not a recommendation to run all of it: pick the layers your stack is missing.
| Layer | Project | Licence | What it does |
|---|---|---|---|
| Web analytics | Matomo | GPL-3.0 | First-party pageviews, goals, funnels and campaign parameters, with the raw visit log exportable. |
| Event analytics | PostHog | MIT (core) | Per-user events, funnels, cohorts and session replay for product-level questions. |
| Tag management | Your own first-party loader | n/a | A container you host, or a 200-line loader of your own — fewer parties, less to break. |
| Consent | Klaro | BSD-3-Clause | Records consent state and gates tags before they fire, not after. |
| Warehouse | PostgreSQL or ClickHouse | PostgreSQL / Apache-2.0 | The join point where spend, sessions and orders become one table set. |
| Modelling | dbt-core | Apache-2.0 | Versioned SQL for sessions, conversions and attribution, with tests that fail the build. |
Evaluation checklist
Answer each of these about your current stack. A ‘no’ is a work item, and the count is a fair summary of the layer’s health.
- Is the collection script served first-party, and does it load without blocking render?
- Does every conversion have a server-side confirmation, not just a browser beacon?
- Is there one canonical event dictionary, versioned, with an owner per event?
- Can you export the raw data without a paid add-on or a support ticket?
- Does the attribution model label itself in every report it feeds?
- Is consent state stored with the event so a later audit is answerable?
What to instrument
Numbers that make the layer’s health visible before a customer complains.
- Purchase events vs orders in the platform (should reconcile within 2%)
- Sessions with a campaign parameter vs sessions with a click id
- Data freshness per source, in hours
- Share of reports whose attribution model is explicit
Where this fits
Scope. This page describes the category and an open-source way to build it. It does not publish 5 Kings’ internal method, client data or vendor terms, and it is not an endorsement of every project listed: check the licence and the maintenance activity against your own constraints before you adopt one.