# Rule index and the manual audit

Thirty-one rules in seven areas. Each line gives the ID, slug, the highest priority the rule can raise and what it protects. Full conditions, reasons, the agent's judgement and the runtime confirmation for each rule live in the family file named in the heading. Severity, priority and scoring: [severity-and-scoring.md](severity-and-scoring.md).

Every rule runs in `scripts/audit-gtm-export.mjs`. Rule IDs R01 to R15 keep their 0.2.0 numbers, slugs and subjects, and a 0.2.0 finding keeps its verdict and wording unless it is listed here (both script versions compared on the same files on 2026-11-06):

- R01: an allow-list exception counts as a consent gate only when R16 shows it can block every firing trigger; one that cannot moves from WARN to FAIL P1.
- R01 and R11: the Google Ads call (`awcc`) and user-provided data (`awud`) tag types are classified now, so they leave the unclassified WARNs; `awcc` with no consent requirement gets its own R01 WARN P2.
- R06: click-based Google Ads and Floodlight actions (call, email, outbound, download) move from FAIL to WARN P2, and a Floodlight counter on every page from FAIL to WARN P3.
- R07: mixed exceptions on Custom HTML and template conversions are compared per vendor, so two different vendors no longer raise a WARN.
- R09: personal-data references moved to R21, and a compromised host moves from the third-party host WARN to FAIL P1.
- R11: a GTM- container ID typed into two tags no longer raises the repeated-ID WARN.
- R14: a workspace export moves from WARN to INFO, never scored.
- R15: a forwarder on an anchored allowlist moves from WARN to PASS, unless a dedicated tag also sends the name (WARN P2).
- R01: with `googleConsentMode` basic in the config, Google tags left "Not set" move from the PASS line to WARN P1 (key basic-unblocked). Without it they stay PASS, and the PASS now says that means advanced mode.
- R19: the 25-parameter FAIL and the 25 user property WARN follow `ga4ParamLimit`, 100 for Analytics 360; `view_complete` joins the enhanced measurement WARN.
- New checks under existing IDs: R02 consent updates; R03 a missing page view and two manual page_view tags; R04 the anti-flicker snippet and a remarketing tag overlapping a Google tag; R07 host scope (`--hosts`); R09 data layer re-assignment, storage writes and polling; R11 the Google Ads action cross-check (`--ads-actions`); R12 value without currency; R13 event IDs (`--server-destinations`).

## Consent and privacy (weight 25): [rules-consent-and-privacy.md](rules-consent-and-privacy.md)

- R01 consent-settings, up to P1: every non-Google tag that sends data or loads vendor code has a consent gate.
- R02 consent-default, up to P1: the consent default is set on Consent Initialization, with all four signals, by one owner, and every update sets all four signals too.
- R16 exception-reach, up to P1: an exception can fire on the same events as the triggers it is meant to block.
- R21 personal-data, up to P1: no personal data reaches GA4 or vendors outside the user-provided data route.

## Conversions and counting (weight 25): [rules-conversions.md](rules-conversions.md)

- R06 conversion-broad-trigger, up to P1: conversions fire on confirmed outcomes, not page loads, clicks or consent changes; click-based actions (call, email, outbound, download) and Floodlight site-visit counters need a decision instead.
- R07 conversion-scoped-trigger, up to P2: trigger scopes match where the conversion really happens.
- R12 ecommerce-data, up to P2: ecommerce events carry items, value, currency and a transaction ID.
- R15 wildcard-events, up to P2: wildcard triggers and event forwarders do not send configuration commands or duplicates.
- R17 firing-options, up to P2: firing options cannot double-send a conversion or hide it from Preview.
- R18 event-pattern-allowlists, up to P2: event-name patterns match only the intended events.
- R29 value-and-id-variables, up to P2: order IDs and values fail visibly instead of defaulting to a constant.

## Google tag and GA4 setup (weight 15): [rules-google-tag-and-ga4.md](rules-google-tag-and-ga4.md)

- R03 duplicate-google-tags, up to P2: one Google tag per ID and exactly one page view path per GA4 ID.
- R05 conversion-linker, up to P2 (runtime): ad click data is stored on every possible landing page.
- R08 tag-sequencing, up to P2: setup tags resolve and each GA4 ID is configured before its events.
- R13 server-transport, up to P2: server routing is first-party and browser plus server copies share an event ID.
- R19 ga4-naming-and-limits, up to P2: GA4 names are valid and inside limits, and key events match exactly.
- R20 google-tag-settings, up to P1: Google tag settings do not corrupt sessions, users or attribution.

## Destinations and duplicates (weight 10): [rules-code-and-destinations.md](rules-code-and-destinations.md)

- R04 retired-tag-types, up to P2: no Universal Analytics, Optimize or obsolete tag types and code.
- R11 destination-ids, up to P2: every destination ID is expected and current, and Google Ads tags match enabled actions.
- R23 duplicate-tags-and-pixels, up to P2: no clones, no vendor base initialised twice, one sender per conversion.
- R24 nested-containers-and-zones, up to P2: any container loaded from inside this one is known and bounded.

## Custom code and security (weight 10): [rules-code-and-destinations.md](rules-code-and-destinations.md)

- R09 custom-html, up to P1: Custom HTML loads no compromised, insecure or retired code and never replaces the data layer.
- R22 exposed-secrets, up to P1: no credential is readable by visitors or by everyone with container access.
- R25 template-permissions, up to P3: templates declare narrow permissions and are not silently edited.
- R26 code-weight, up to P4: heavy custom code is visible so container size can come down.
- R27 custom-javascript-variables, up to P2: Custom JavaScript variables return a value, have no side effects and never replace the data layer.

## Triggers, variables and data layer (weight 10): [rules-structure-and-governance.md](rules-structure-and-governance.md)

- R10 paused-orphaned-broken, up to P2: no broken references, and dead items are known.
- R28 trigger-hygiene, up to P3: triggers are not unbounded, slow or duplicated.
- R30 data-layer-contract, up to P2: triggers listen for the exact events the tracking plan says the site pushes.

## Versions, workspaces and naming (weight 5): [rules-structure-and-governance.md](rules-structure-and-governance.md)

- R14 version-hygiene, up to P2 (outside the file): the audited file is the live version and releases are traceable; a workspace export is reported as INFO, not scored.
- R31 naming-and-organization, up to P3: names say what an item is and whether it is live.

## Server containers

The script detects `usageContext` SERVER and runs R08, R10, R11, R14, R22 (WARN P3 only, because server containers are not sent to browsers), R25 and R31, then prints a hand-off inventory: clients, tags and triggers by type, the transformation count, and tags whose triggers have no event-name condition. Server container type codes are not documented publicly, so everything else goes to server Preview and the host's request logs with [../assets/server-handoff-template.md](../assets/server-handoff-template.md).

## How to audit by hand when the script cannot run

Label the report "script not run" and work in this order, because later rules depend on earlier answers:

1. Baseline and completeness: confirm the file is the live version (R14) and that every referenced trigger and variable exists (R10). A partial read makes every later rule unreliable; fix the read first.
2. Consent: find the default owner and its trigger (R02), then rate every non-Google tag's gate (R01), checking that each exception fires on the same events as the tag's triggers (R16), then personal data (R21).
3. Conversions: list every conversion tag (Google Ads, Floodlight, GA4 conversion events, ad platform purchase or lead events), then R06, R07, R17, R18, R29, R12 and R15 per tag.
4. Google tag: one Google tag per ID and one page view owner (R03), sequencing (R08), names and limits against the GA4 rules page (R19), settings rows (R20), routing (R13), linker (R05).
5. Destinations and code: secrets first (R22, P1), then R09, R11, R23, R24, R04, R25, R27, R26.
6. Structure: R28, R30, R31.

Record each finding with an ID in the script's format, `<rule>:<entity type>:<entity ID>:<short key>` (for example `R01:tag:9:no-gate`), so exceptions, evidence and a later script run line up. Score by hand with [severity-and-scoring.md](severity-and-scoring.md).
