--- description: GTM QA - tag firing verification, trigger testing, naming conventions, cross-platform validation --- # GTM Validator Verify GTM implementations on live pages. Test triggers, validate dataLayer, check naming conventions. ## Pre-Flight **BEFORE starting validation**, read the relevant gotcha files at: `~/Project/dintel-gtm-agent/docs/log/gotcha/` (see `README.md` for index) Priority reads per task: - **Trigger validation** → `gotcha/triggers.md` + `gotcha/regex.md` - **Post-API-change QA** → `gotcha/compilation.md` - **Variable inspection** → `gotcha/variables.md` ## Triggers - "validate tags", "QA GTM", "debug GTM" - "naming conventions", "GTM best practice" ## MANDATORY: Knowledge Base Read/Write **Before starting any validation or QA:** 1. Identify the target client from container ID or URL 2. Read `knowledge-base/accounts//profile.md` — naming conventions, known issues, platform stack 3. Read `knowledge-base/accounts//*.md` — taxonomy defines expected events; naming fix plans reveal known violations 4. Skim `knowledge-base/logs//` — past QA reveals recurring issues and known false positives **After completing validation, write a session log:** - Write to `knowledge-base/logs//YYYY-MM-DD-.md` - Include: date, container ID, pass/fail results, broken triggers (IDs), new naming violations - Update `knowledge-base/accounts//profile.md` if you discovered persistent facts - See `AGENTS.md` for full format template ## Validation Modes ### 1. Tag Firing Verification Navigate to page -> capture network requests -> compare expected vs actual tags ### 2. Trigger Condition Testing Extract CSS selectors from trigger config -> test on live DOM -> flag 0-match (CRITICAL) or too-many-match (WARNING) ### 3. DataLayer Schema Validation Check required fields per GA4 event (purchase: transaction_id, value, currency, items[]) ### 4. Naming Convention Check - Tags: `[Platform] - [event_name] [context]` - Triggers: `[Type] - [description] Trigger` - Variables: `[prefix] - [description]` (dlv, cjs, aev, jsv, URL, cookie, c) ### 5. Cross-Platform Event Mapping Verify same action sends correct events to GA4, Meta, Google Ads, Kakao, Naver ### 6. QA Checklist GTM snippet placement, dataLayer init, consent mode, ES5 compliance, sGTM endpoint ### 7. Version Comparison Compare tag counts and changes between container versions ## Gotchas (Hard-Won Lessons) ### GTM Has Two Validation Layers — API CRUD vs Preview/Publish GTM API validates **schema only** during create/update calls (field names, types, required params). Regex patterns are stored as opaque strings and **never compiled** at edit time. Preview/Publish performs **full container compilation** — all regex is compiled by Google RE2, all variable references resolved, cross-resource dependencies checked. A resource can pass API validation but break Preview. **Rule**: After batch API changes, always attempt Preview before declaring success. ### RE2 Does Not Support Lookaheads GTM's regex engine (RE2) is linear-time and deliberately omits: - Negative lookahead `(?!...)` - Positive lookahead `(?=...)` - Lookbehind `(?<=...)` / `(?