# Runtime tests: rules for live systems and the case catalogue

A finding is a lead until runtime evidence confirms it. Run a case for every P1 and P2 FAIL and every conversion-related WARN, record the result in the runtime evidence file ([../assets/runtime-evidence-template.json](../assets/runtime-evidence-template.json)), and re-run the script with `--evidence` so the score and status reflect confirmed and refuted findings.

## Rules on live systems

- Preview and Tag Assistant send real requests to live GA4, Google Ads, Meta and other destinations, and a test order or lead is a real record in the business's systems.
- Never submit a form, place an order, click a consent banner or push a test event on a live site without the user's explicit approval for that test. Approval is per test, not per audit.
- Run order and lead tests on staging, or with the platform's test payment method and an agreed test order reference (for example ACME-TEST-001). Use GA4 debug mode or a test property, and the platform's test event code where one exists.
- Tell the Google Ads owner which test conversions to expect so they can exclude them. List every destination record a test creates in the change list.
- Use a fresh browser profile with no extensions for each consent state. Record browser, region, consent choice, page and time.
- Count unique order IDs as well as requests. In one fictional test, 100 orders produced 103 purchase requests while 8 orders sent nothing: request totals hid both defects.
- Never paste customer data, cookie values or credentials into the evidence file. Store HAR files and screenshots in the audit folder and reference them by name.

## Case catalogue

### Consent (R01, R02, R16)

- Steps: no choice, reject all, accept all, each in a fresh profile; a returning visitor with a saved choice; for R16, the firing event with the exception condition true.
- Evidence: Tag Assistant consent state per signal (On-page Default and Update), vendor requests per case, cookie names written.
- Pass: no non-Google request before a choice or after reject; Google requests follow the documented basic or advanced mode; the excepted tag appears under Tags Not Fired.
- Update (R02): after accept all, the Update state shows all four signals granted. ad_user_data or ad_personalization still denied confirms an update-missing-signals finding.
- Full region-by-choice matrices, gcs and gcd decoding and HAR evidence: the consent-debugging skill.

### Conversions (R06, R07, R17, R18, R29)

- Steps: a rejected submission, a double click, a successful submission, a reload of the success page, the business event on each host in scope, near-miss event names on staging, an order without an ID on staging.
- Evidence: count of outgoing conversion requests per case, with the order ID each carried.
- Pass: exactly one request per successful conversion and none otherwise; no default order ID.

### Page views and the Google tag (R03, R08, R19, R20)

- Steps: one page load and one single-page app route change in a fresh profile.
- Evidence: `en=page_view` count per measurement ID, session_start on the first request, no debug flag, exact event names in GA4 Realtime (or the GA4 MCP server's realtime report with dimension eventName).
- Pass: one page view per load or route; names match key events exactly; no debug flag in production.
- Debug flag: Preview and Tag Assistant turn on debug mode for the tester's own browser, so check the debug flag only on requests sent without Tag Assistant (a fresh profile, no gtm_debug parameter). An R20 finding is confirmed or refuted from those requests, never from a Preview session.

### Duplicates and loaders (R09, R14, R23, R24, R27)

- Steps: one page load per page type with `scripts/page-inventory.js`.
- Evidence: base requests per vendor ID, loaded container IDs, loader parameters, the "GTM listening to" line for the data layer.
- Pass: one base request per pixel ID; only expected containers; no environment parameters on production; the container still listens to its data layer after the page has run its own code.

### Linker (R05)

- Steps: open a landing URL with a test gclid (for example `?gclid=TEST-GCLID-001`) in Preview.
- Evidence: first-party `_gcl` cookies or local storage entries (names only).
- Pass: click data stored. If it is, mark the R05 WARN refuted.

### Server hand-off (R13)

- Steps: one test purchase with server Preview open.
- Evidence: the browser eventID and the server event_id; the vendor's test events view.
- Pass: the same ID on both copies and the vendor reports them deduplicated.

### Secrets (R22)

- Steps: none in the browser. The owner rotates the secret at its source; then re-run the script.
- Evidence: the owner's confirmation that the old secret is deleted; R22 PASS on the re-run.
- Never test whether an exposed secret works.

## Recording a result

```json
{
  "finding": "R06:tag:10:consent-event-15",
  "status": "confirmed",
  "evidence": "Staging, fresh profile, Tag Assistant: two banner clicks sent two Meta Purchase requests with no order; HAR meta-consent-clicks.har",
  "by": "web analytics lead",
  "date": "2026-11-01",
  "approval": "staging only, approved by the paid social owner"
}
```
