# Design: a website's data layer and tags, checked in a browser before release

Written and committed before any release was scored. Anything settled after a result was read is listed on the page under
"Added later, and why" and never changes a number declared here. The frozen settings are in `web/protocol.json`.

## Overlap test: why this is a round of event contracts and not a new study

The app round asks whether tracking breaks silently between releases and what a pre-release contract catches, on a
simulated app whose emitter is a Python function. This round asks the same question on a different surface. A website has
layers an app round cannot show: a data layer the page fills, a tag layer that decides what leaves the browser, a consent
banner that gates it, client-side routes, campaign values carried in URLs through redirects, and a tag configuration
published outside the site's build. Three things no published page answers:

1. What does a check of the data layer alone miss, when the break sits between the data layer and the browser's outgoing
   requests?
2. How much do browser states (consent choices, campaign entry, phone layout, double clicks) add to a scripted check?
3. What can a pre-release check do about the changes that never pass through a release (a tag publish, a redirect rule, a
   vendor's script), and does replaying the same sessions each morning close that gap?

It reuses the app round's way of scoring: wrong metric-days, days to a find, monitoring thresholds and the idea of an
independent author. It does not reuse its app, changes, checks or results. The neighbouring identity study asks how counts
drift as identity signals fade; here every visitor is one session, and identity is out of scope.

All work on any analytics vendor's real export belongs elsewhere. This round names no vendor; its tag layer is a small
open script written for the study.

## Data: explicitly synthetic

Fernhollow, a fictional B2B software company, has a real small website in `web/site/`: seven HTML pages, a data layer, a
consent banner, a tag layer with its own configuration, client-side routes in the resources section and two forms. The
measurement framework, event taxonomy and data layer specification are `web/FRAMEWORK.md` and the JSON schemas in
`web/site/spec/`.

**Journeys run in a real browser.** A journey is one combination of 4 entries (direct, search, paid campaign through a
redirect, newsletter link with UTM parameters), 4 consent behaviours (accept at once, accept after 4 seconds, reject,
ignore), 2 devices (desktop, phone layout) and 6 paths (bounce, read with client-side routes and the back button, pricing
and plan choice, demo request, demo request with a failed first try and a double click, gated guide): 192 journeys.
Every journey runs in a fresh context of a headless Chromium against the release's actual files, with a fake clock for time
on page and a seeded random source. Each run records the visitor's actions, every data layer push and every outgoing hit.

**Traffic is an expansion of those traces.** For a day, the count of visitors on each journey is Poisson with mean 1,400
(weekends 0.35 of that) times a day factor (normal, standard deviation 8%) times the journey's share. Shares are the
product of entry, consent and device shares and the path share given the entry (`web/protocol.json`). 98.5% of a
journey's visitors land; the rest are lost to blocked or dropped requests, on the clean build too. Seeds 1 to 20; every
draw comes from a stream keyed by the seed, the day and the journey. So the browser fixes what each kind of visitor
sends under a build, and the world fixes how many visitors of each kind come. No visitor returns: one session each.

**Truth.** A journey's truth comes from what the visitor did in the browser under that build: its pages, its plan, its
submitted forms. People who reject or ignore the banner count as zero, because a correct build sends nothing about them.
A visitor who meant to accept and never saw the banner counts as measured. Before any release, the clean build must land
exactly its truth on all 192 journeys.

**Metrics.** The seven in `web/FRAMEWORK.md`: visitors, pages per visitor, demo requests, pricing to demo conversion, paid
share of demo requests, pipeline value and guide leads. A metric is **wrong** on a day when it differs from the truth by more
than its tolerance: 2% relative, or the 99th percentile of the clean build's own daily error on that metric over the 42
warm-up days of all seeds, whichever is larger. A release is **metric-breaking** when, left alone, it makes at least 3
metric-days wrong in the 28 days from release (mean over the seeds). These metric-days are not comparable with the app
round's: other metrics, other counts of series.

## Releases

42 warm-up days, then one release every 7 days, each scored on its own against the clean build, so changes never mask one
another (a declared assumption: real releases bundle changes). A website reaches everyone at once, so there is no gradual
adoption. A release is a set of real code patches on the site, shipped on one of four channels: `site_build`,
`tag_publish`, `edge_rule` and `vendor_script` (`web/FRAMEWORK.md`).

The 27 releases I wrote are in `web/releases/declared.json`, with my prediction for each. They include the six kinds named
in the question that started this round: a renamed form field, a consent banner that delays tags, a client-side route
change with no page view, duplicate firing, a UTM stripped by a redirect, and a value sent as text.

## Held-out releases

An independent author who never saw the checks, the sessions, the journeys, the thresholds or my releases gets the site's
source, `web/FRAMEWORK.md` and `web/RELEASE_FORMAT.md`, and writes 12 releases as real code patches. Unlike the app round's
author, it is not limited to a grammar of operations I chose: it can change any line of the site. It runs once, read-only,
from a clean folder holding only those files; inputs and outputs are hashed. Its releases are kept as written and scored by
the same code as mine. A patch that does not apply is reported and not repaired. Its releases are committed before the
first scored run.

## Arms

1. **Dashboards only.** Someone notices when a metric moves more than 30% from its mean over the previous 28 days.
2. **Monitoring after release.** Daily checks on landed hits, the same thresholds as the app round, read the morning after
   each data day:
   - schema: per planned event, more than 1% of the day's events (and at least 5) failing a required property, type,
     allowed value or range; or an unplanned event name with at least 20 events. Unknown properties are ignored.
   - volume: per planned event, the day's count under 0.7 or over 1.4 times the mean of the same weekday over the previous
     4 weeks (when that mean is at least 20).
   - metrics: a metric more than 3 standard deviations from its mean over the previous 28 days.
3. **Plain check before release: the data layer in scripted sessions.** Runs on every `site_build` release only. Three
   sessions on desktop, entering directly or from search, accepting consent at once: a demo request, a read through the
   client-side routes with the back button, and the gated guide. It asserts that every data layer push passes the strict
   schema of the release's own specification (unknown properties fail), that the session reaches its end with no page error,
   and that each session pushes exactly the events its actions call for: one `page_view` per page visited, one
   `plan_selected`, one `cta_click`, one `form_start`, one `form_error` per failed submit and one lead event. It never
   looks at what leaves the browser.
4. **Plain check and monitoring** (3, then 2 for what ships).
5. **Full browser check and monitoring.** The plain check, plus the outgoing hits, in 14 sessions (`web/protocol.json`) that
   add campaign entry, reject, ignore, late consent, phone layout and the double click. It runs on `site_build` and on
   `tag_publish` through a preview of the tag configuration. It adds these assertions:
   - every hit passes the strict hit schema;
   - exactly one hit per expected event, with that event's id, in accepting sessions;
   - no hit at all in reject and ignore sessions, and none before the decision in any session;
   - one visitor id and one session id per session;
   - on each `page_view` and lead hit, the channel and campaign values the session's entry should give;
   - the lead hit's plan and annual value match what the visitor chose.
   `edge_rule` and `vendor_script` changes pass through no release, so it cannot see them.
6. **Full check, monitoring and a morning replay.** The same 14 sessions and assertions, each morning, against the live site.
   Any channel. A release the replay would fail is found on the first morning after it ships.

Every arm keeps the dashboard reader after release.

**Found.** A pre-release catch means the release never ships: no wrong day. After release, a release is found on the first
morning an alarm fires, on a data day on or after the release, when (a) the alarm is on an affected element, and (b) the
clean build, on the same seed and data day, raises no such alarm (same check, same element). Affected elements are an event
whose landed count over the 28 days differs from the clean build by more than 1%, whose schema failure share differs by
more than 0.5 points, a new event name, or a metric the release made wrong. For a real behaviour change, the affected
metrics are those whose true value moved by more than the tolerance. The app round added the clean-build condition after its
results; here it is declared in advance. An alarm is assumed to lead the team to the release the same day, which is generous
to monitoring.

A release is **wrong** on the data days before it is found, up to the data day whose alarm found it: the alarm read on morning
d + 1 about data day d leaves d wrong and fixes d + 1 onward. No backfill. Not found in 28 days counts all 28.

## What is true by construction

A check stops what its assertions name. A value of the wrong type fails a schema because that is what a schema does. The
measured part is what each check lets through, how long monitoring takes on it, and the damage meanwhile. The page says so.
My releases are a self-test: I wrote the releases, the sessions and the assertions. The independent author's are the
real test, and the headline leads with them. The 14 sessions were written with my releases in mind.

## Measures

Per release, arm and seed: stopped before release, found after (days after the release) or not found in 28 days; wrong
metric-days. Alarms on releases that broke no metric. Alarm days on the 42 clean warm-up days. Reported per set of
releases and per arm, never pooled across the declared and held-out sets. Journey runs that a release left unfinished, and
page errors, are counted per release.

## Sensitivity (declared)

On all seeds, one at a time: the metric band (2, 4 standard deviations), the volume band (0.8 to 1.25, 0.6 to 1.6), the
tolerance floor (1%, 5%), traffic (a third, three times) and the landed share (99.5%, 95%).

## Predictions (declared)

1. The plain check stops the breaks visible in the data layer of its three sessions: 4 of my 19 predicted breaks (a route
   with no page view, a back button with no page view, a double page view, a value as text). It stops no break that sits in the tag
   layer, the consent banner, a campaign entry or the phone layout.
2. The full check stops 17 of my 19 predicted breaks: all but the two that ship outside a release.
3. On the independent author's releases, the full check stops a smaller share of the breaking releases than on mine.
4. Monitoring finds the loud breaks on the first morning, a median of at most 2 days among those it finds, and misses the
   lost double-submit guard and the monthly billers' value on most runs.
5. Monitoring raises an alarm on both real behaviour changes, which break no metric.
6. The morning replay finds both breaks that ship outside a release on the first morning.
7. Each release's own prediction (`web/releases/declared.json`) holds for at least 80% of the 27.

## What would change the conclusion

If monitoring found quiet breaks within 2 days, the case for a pre-release check would rest on avoiding the first day's
damage. If the plain check stopped most of the independent author's breaks, the hits and browser states would add little,
and a schema on the data layer would be enough. If the full check stopped no more of the author's breaks than the plain one,
the 14 sessions would only fit the breaks I imagined.

## Limits declared now

One browser engine, so nothing about another browser's cookie or privacy rules. A stand-in tag layer of about 100 lines, so
nothing about a real tag manager's preview, versions, built-in triggers or server-side mode. One session per visitor. Redirect
rules applied by the harness, not by a real network. The traffic shares are assumptions, moved in the sensitivity runs.
