Loading...
Loading...
Plain-language fix guide for failing GTM tests. Use when tests have failed and the developer needs step-by-step instructions to fix each issue. Reads gtm-test-results.json and writes a fix guide in plain English - no GTM expertise required to follow. No API calls. Trigger on - "fix guide", "how do I fix failing tests", "tests failing", "gtm test failures", "fix my tracking", "what broke".
npx skill4agent add aimonk2025/google-tag-manager-automation gtm-fix-guidegtm-context.mdCheck for gtm-test-results.json in the project root.
If not found:
"No gtm-test-results.json found. Run gtm-testing first to generate test results, then re-run this skill."
Stop.
If found:
Read the file.
Count: total tests, passed, failed.
Extract all failed tests with their failure details.Found gtm-test-results.json
Total tests: X
Passed: X (✓)
Failed: X (✗)
Generating fix guide for X failing tests...All X tests passed. No fixes needed.| Symptom in test result | Likely cause |
|---|---|
| "dataLayer event not found" | Event name mismatch or push not called |
| "parameter missing" | dataLayer.push missing expected key |
| "wrong event name" | Typo or case mismatch in event name |
| "trigger not firing" | CSS selector changed, trigger condition wrong |
| "tag not found in network" | Tag paused, trigger mismatch, or container not published |
| "event fired X times, expected 1" | Duplicate listener, event bubbling, page refresh |
| "parameter value null/undefined" | DOM element not found when push fires |
| "wrong parameter value" | Data source mapping incorrect |
gtm-fix-guide.md# GTM Fix Guide
Generated from gtm-test-results.json
Tests failing: X of Y
Date: [current date]
---
## Summary
| # | Test | Failure | Likely Cause | Effort |
|---|------|---------|--------------|--------|
| 1 | [test name] | [short failure] | [cause] | [Low/Medium/High] |
...
---
## Fix Instructions
### Fix 1: [Test Name]
**What this test was checking:**
[Plain English: "This test checks that when a user clicks the Buy Now button, a purchase event is sent to Google Analytics."]
**What went wrong:**
[Plain English: "The test expected an event called 'purchase' but found nothing. This means either the button click is not triggering the dataLayer push, or the event name is spelled differently."]
**Likely cause:**
[Most probable technical reason based on failure type]
**How to fix it:**
Option A - If the dataLayer push is missing from your code:
1. Open [file or component where the element lives]
2. Find the [button/form/element] handler
3. Add this code:
```javascript
window.dataLayer = window.dataLayer || [];
window.dataLayer.push({
event: '[expected event name]',
[parameter]: [value]
});dataLayerevent: "[event name]"
### Phase 4: Console Summary
After writing the file, display:
## Important Guidelines
- Write for developers, not GTM specialists - explain GTM concepts briefly when referenced
- For each failure, always provide both "fix in code" and "fix in GTM" options where applicable
- Never assume the fix is only one thing - present the most likely cause first, alternatives second
- Effort estimates: Low = typo/rename, Medium = code change + GTM config, High = architectural issue
- Do not make API calls or modify any GTM configuration - this skill is read and write to local files only
- If the test result JSON has no error details, note that and provide generic diagnostic steps
## Output Files
**gtm-fix-guide.md** - Plain-language fix instructions for every failing test
## Handoff / Next Steps
After the user applies fixes, they should:
1. Re-run gtm-testing to confirm all tests pass
2. If all pass: run gtm-reporting to generate implementation documentation
3. If new failures appear: run gtm-fix-guide again on the updated test results