Agents must now read client profiles before GTM work and write session logs after completing audits, tag changes, or validation — ensuring findings compound across sessions instead of being lost. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
83 lines
3.5 KiB
Markdown
83 lines
3.5 KiB
Markdown
---
|
|
description: GTM page audit - scan fired tags, gap analysis, tag design from DOM, and report generation
|
|
---
|
|
|
|
# GTM Audit
|
|
|
|
Comprehensive Google Tag Manager audit using Playwright to scan live pages for container health, tag firing, dataLayer events, form tracking, and e-commerce checkout flows.
|
|
|
|
## MANDATORY: Knowledge Base Read/Write
|
|
|
|
**Before starting any audit:**
|
|
1. Identify the target client from container ID or URL
|
|
2. Read `knowledge-base/accounts/<client>/profile.md` — URL patterns, known issues, platform stack, past findings
|
|
3. Read `knowledge-base/accounts/<client>/*.md` — taxonomy, naming issues to exclude from new findings
|
|
4. Skim `knowledge-base/logs/<client>/` — past session context
|
|
|
|
**After completing audit, write a session log:**
|
|
- Write to `knowledge-base/logs/<client>/YYYY-MM-DD-<description>.md`
|
|
- Include: date, container ID, status, issues found (root causes + specific IDs), lessons learned
|
|
- Update `knowledge-base/accounts/<client>/profile.md` if you discovered persistent facts
|
|
- See `AGENTS.md` for full format template
|
|
|
|
## Triggers
|
|
- "audit GTM", "check dataLayer", "GTM 검사", "scan GTM tags", "audit tags on page", "check tag firing"
|
|
|
|
## Capabilities
|
|
|
|
1. **Container Analysis** — Verify GTM container loads, detect container ID, inventory tags/triggers/variables
|
|
2. **Tag Destination Detection** — Identify fired tags by network requests (GA4, Google Ads, Meta Pixel, LinkedIn, TikTok, Kakao, Naver, etc.)
|
|
3. **DataLayer Validation** — Check event structure, required fields, GA4 naming conventions
|
|
4. **Form Tracking** — Verify form submission events and field capture
|
|
5. **E-commerce Checkout Flow** — Validate purchase/cart/checkout events and required e-commerce parameters
|
|
6. **Journey-based Audit** — Target specific user journeys: `pageview`, `scroll`, `click`, `form`, `checkout`, `datalayer`, or `full`
|
|
|
|
## Script
|
|
|
|
```bash
|
|
AUDIT_SCRIPT="/Users/ourdigital/Project/our-claude-skills/custom-skills/60-gtm-audit/code/scripts/gtm_audit.py"
|
|
|
|
# Basic page audit
|
|
python "$AUDIT_SCRIPT" --url "https://example.com"
|
|
|
|
# Audit with expected container ID and specific journey
|
|
python "$AUDIT_SCRIPT" --url "https://example.com" --container GTM-XXXXXX --journey full
|
|
|
|
# E-commerce checkout flow audit with JSON report
|
|
python "$AUDIT_SCRIPT" --url "https://example.com/checkout" --journey checkout --output report.json
|
|
```
|
|
|
|
### Script Options
|
|
| Flag | Description | Default |
|
|
|------|-------------|---------|
|
|
| `--url` | Target URL to audit (required) | — |
|
|
| `--container` | Expected GTM container ID (e.g., GTM-XXXXXX) | auto-detect |
|
|
| `--journey` | Audit scope: `pageview`, `scroll`, `click`, `form`, `checkout`, `datalayer`, `full` | `pageview` |
|
|
| `--output` | Output file path for JSON report | `gtm_audit_report.json` |
|
|
| `--timeout` | Page load timeout in ms | `30000` |
|
|
| `--headless` | Run in headless mode | `True` |
|
|
|
|
## Audit Checklist
|
|
|
|
### Container Health
|
|
- [ ] GTM container loads without JavaScript errors
|
|
- [ ] Container ID matches expected value
|
|
- [ ] No duplicate container installations
|
|
|
|
### Tag Firing & Destinations
|
|
- [ ] GA4 measurement requests detected
|
|
- [ ] Ad platform pixels fire correctly (Google Ads, Meta, etc.)
|
|
- [ ] No orphaned or misfiring tags
|
|
|
|
### DataLayer Events
|
|
- [ ] `page_view` fires on all pages
|
|
- [ ] `purchase` event has required e-commerce fields
|
|
- [ ] Form submissions tracked with correct parameters
|
|
- [ ] Event names follow GA4 snake_case convention
|
|
|
|
### Common Issues
|
|
- Missing or malformed ecommerce object
|
|
- Incorrect event names (not GA4 format)
|
|
- Duplicate event firing
|
|
- Tags firing before dataLayer is ready
|