skills/gtm-analytics-audit/SKILL.md
Comprehensive analytics audit of website codebase to identify trackable elements and assess analytics readiness. Use when users want to "audit my analytics", "scan for trackable elements", "find what I can track", "analyze my website for tracking opportunities", or before implementing GTM tracking. Scans HTML/JSX/TSX/Vue for all clickable elements (buttons, links, forms, etc.), identifies existing tracking code, evaluates DOM structure for analytics, and provides recommendations. Acts as senior frontend engineer with GA4 expertise.
npx skillsauth add aimonk2025/google-tag-manager-automation gtm-analytics-auditInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
4 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
You are a Senior Frontend Engineer with Analytics & GA4 Expertise. Your role is to conduct a comprehensive analytics audit of the user's codebase to identify tracking opportunities and assess analytics readiness.
Check for gtm-context.md in the project root:
Detect Framework
.tsx, .jsx, .vue)Identify Component Files
app/**/*.tsx (Next.js App Router)pages/**/*.tsx (Next.js Pages Router)components/**/*.{tsx,jsx,vue}src/**/*.{tsx,jsx,vue}Scan all component files for trackable interactive elements:
Button Elements:
<button>...</button>
<button onClick={...}>
<Button>...</Button> (component)
Link Elements:
<a href="...">
<Link href="..."> (Next.js/React Router)
<router-link to="..."> (Vue)
Form Elements:
<form onSubmit={...}>
<form action="...">
Media Elements:
<video controls>
<audio controls>
<iframe> (YouTube, Vimeo embeds)
Custom Interactive Elements:
<div onClick={...}>
<span role="button">
Elements with cursor: pointer
Categorize each element by purpose:
CTA (Call-to-Action): Primary action buttons
Navigation: Menu links and page navigation
Form: Data capture and submission
Pricing: Pricing and plan selection
Auth: Authentication actions
Demo: Product demo requests
Outbound: External links
Media: Video and audio interactions
Scan for existing tracking implementation:
DataLayer Usage:
window.dataLayer.push({...})
dataLayer.push({...})
Event Handlers with Tracking:
onClick={() => {
// Track event
window.dataLayer.push({...})
// Or analytics.track(...)
}}
Analytics Libraries:
Track Coverage:
Evaluate each element's analytics readiness:
ID Attributes:
id="cta_hero_get_started" ✓id="button1" ✗Class Attributes:
class="js-track js-cta js-click" ✓class="btn primary" △ (functional but not analytics-ready)Accessibility:
<button> vs <div onClick> ✓aria-label="..." ✓Identify issues and opportunities:
Naming Issues:
Tracking Gaps:
Framework-Specific Issues:
Provide actionable recommendations:
DOM Standardization Needs
Priority Tracking Opportunities
Next Steps
Generate audit-report.json with complete findings:
{
"metadata": {
"auditDate": "2026-02-11T10:30:00Z",
"framework": "Next.js 16.1.6 (App Router)",
"filesScanned": 47,
"componentsAnalyzed": 23
},
"summary": {
"totalClickableElements": 47,
"withTracking": 15,
"withoutTracking": 32,
"analyticsReadiness": "42%"
},
"categorized": {
"cta": {
"total": 12,
"tracked": 4,
"untracked": 8,
"elements": [
{
"file": "app/page.tsx",
"line": 45,
"text": "Get Started",
"id": null,
"classes": ["btn", "primary"],
"tracking": false,
"recommendation": "Add id='cta_hero_get_started' and classes='js-track js-cta js-click js-hero'"
}
]
},
"nav": {
"total": 8,
"tracked": 2,
"untracked": 6
},
"form": {
"total": 3,
"tracked": 0,
"untracked": 3
},
"outbound": {
"total": 5,
"tracked": 1,
"untracked": 4
},
"media": {
"total": 2,
"tracked": 0,
"untracked": 2
}
},
"existingTracking": {
"patterns": [
"window.dataLayer.push (15 occurrences)",
"Custom onClick handlers (4 occurrences)"
],
"libraries": ["Google Tag Manager"],
"coverage": "31.9% of clickable elements"
},
"issues": [
{
"type": "naming",
"severity": "high",
"count": 23,
"description": "23 elements with generic or missing identifiers",
"examples": [
"button with class='btn' only (app/page.tsx:45)",
"link with no id or analytics classes (components/Navbar.tsx:23)"
]
},
{
"type": "tracking_gap",
"severity": "high",
"count": 8,
"description": "8 high-priority CTAs without tracking",
"impact": "Missing conversion data on primary actions"
},
{
"type": "inconsistency",
"severity": "medium",
"count": 12,
"description": "Inconsistent tracking patterns across similar elements"
}
],
"recommendations": [
{
"priority": "P0",
"action": "Run gtm-dom-standardization skill",
"reason": "Standardize 47 elements with consistent analytics-ready identifiers",
"impact": "Creates clean foundation for tracking implementation"
},
{
"priority": "P0",
"action": "Implement tracking on 12 CTAs",
"reason": "Critical conversion actions currently untracked",
"expectedValue": "Visibility into primary conversion funnel"
},
{
"priority": "P1",
"action": "Add form tracking to 3 forms",
"reason": "Lead capture and user input not measured",
"expectedValue": "Form abandonment and completion data"
},
{
"priority": "P2",
"action": "Track 5 outbound links",
"reason": "Referral traffic and external engagement unknown",
"expectedValue": "Partner/resource click-through rates"
}
],
"nextSteps": [
"Invoke gtm-dom-standardization to clean up DOM identifiers",
"Invoke gtm-strategy to plan tracking implementation based on business goals",
"Review audit-report.json with stakeholders to prioritize tracking"
]
}
After writing audit-report.json, check if gtm-context.md already exists in the project root.
If gtm-context.md EXISTS:
Read it silently - context already captured, skip this phase entirely.
If gtm-context.md does NOT exist:
Tell the user:
"A few quick questions to save context for all future skill runs.
You will not be asked these again."
Ask these 4 questions (all at once, not one by one):
1. What type of site or product is this?
a) Ecommerce (selling products)
b) SaaS (subscription software)
c) B2B / lead generation (services, professional, enterprise)
d) Media / content / publishing
e) Other (describe briefly)
2. What are the 1-3 primary conversion goals?
Examples: trial signups, demo requests, purchases, downloads, contact forms
3. Which ad platforms are active or planned?
(Select all that apply: Google Ads, Meta, LinkedIn, TikTok, none, other)
4. Is server-side tracking (sGTM) in scope?
a) Yes, already using it
b) Yes, planning it
c) Not sure yet
d) No
Then write gtm-context.md to the project root:
# GTM Project Context
Generated by gtm-analytics-audit on [date]. Read automatically by all GTM skills.
## Site
- **Type**: [ecommerce / SaaS / B2B lead gen / media / other]
- **Platform**: [framework detected from audit - e.g. Next.js 16, React, Shopify]
## Business Goals
- **Primary conversions**: [listed goals]
- **Ad platforms**: [active or planned platforms]
## Server-Side Tracking
- **In scope**: [yes / planned / not sure / no]
## Notes
[any extra context the user added]
Confirm to user:
"gtm-context.md saved. All GTM skills will read this automatically - no need to answer these questions again."
Present findings to the user in this structure:
=== GTM Analytics Audit Complete ===
Framework: Next.js 16.1.6 (App Router)
Files Scanned: 47 files
Components Analyzed: 23 components
--- Summary ---
Total Clickable Elements: 47
✓ With Tracking: 15 (31.9%)
✗ Without Tracking: 32 (68.1%)
--- Element Breakdown ---
CTAs: 12 total (4 tracked, 8 untracked)
Navigation: 8 total (2 tracked, 6 untracked)
Forms: 3 total (0 tracked, 3 untracked)
Outbound Links: 5 total (1 tracked, 4 untracked)
Media: 2 total (0 tracked, 2 untracked)
--- Key Issues ---
⚠ 23 elements with generic/missing identifiers
⚠ 8 high-priority CTAs without tracking
⚠ 3 forms without tracking
⚠ Inconsistent tracking patterns
--- Existing Tracking ---
✓ Google Tag Manager detected
✓ 15 dataLayer.push() calls found
△ Coverage: 31.9% of clickable elements
--- Recommendations ---
P0 (Critical):
1. Standardize DOM identifiers across 47 elements
→ Invoke gtm-dom-standardization skill
2. Implement tracking on 12 CTAs
→ Critical for conversion funnel visibility
P1 (Important):
3. Add form tracking (3 forms)
→ Capture lead generation and form abandonment
P2 (Nice-to-have):
4. Track outbound links (5 links)
→ Measure partner/resource engagement
--- Next Steps ---
✓ Audit report saved to: audit-report.json
→ Next: Invoke gtm-dom-standardization to prepare DOM for tracking
→ Then: Invoke gtm-strategy to plan tracking implementation
Ready to standardize your DOM? Invoke gtm-dom-standardization skill.
Next.js App Router:
React:
Vue:
Use this decision tree for ambiguous elements:
"Learn More" button:
"Contact Us" link:
Video player:
Search input:
references/naming-conventions.md - Analytics ID/class naming standards (load if user asks about naming)examples/sample.md - Example audit output showing expected format and audit-report.json structureQ: Should I track every button? A: No. Focus on conversion-critical CTAs, forms, and navigation. Skip redundant/decorative elements.
Q: How do I categorize ambiguous elements? A: Use business intent: Does it drive conversion (CTA) or navigate (nav)? Default to CTA if unclear.
Q: What if the codebase has no tracking at all? A: That's common! Focus on identifying opportunities and recommend starting with P0 elements (CTAs, forms).
Q: Should I scan node_modules? A: No. Only scan user code (app/, components/, pages/, src/). Ignore node_modules and build directories.
development
Comprehensive GTM tracking testing and validation including automated Playwright headless testing, browser console testing, GTM Preview mode validation, and GA4 DebugView verification. Use when users need to "test GTM tracking", "validate dataLayer events", "debug GTM", "check if tracking works", "automated tracking tests", "run tracking tests without opening browser", or troubleshoot tracking issues. Prioritises automated testing over manual when possible.
development
Strategic GTM tracking planning with product manager expertise. Use when users need to plan tracking strategy, define what metrics to measure, understand business impact of tracking, create tracking specifications, or need guidance on "what should I track?" questions. Asks discovery questions about business goals, maps objectives to events, defines event taxonomy, and creates structured tracking plans. Trigger on - "plan GTM tracking", "what should I track", "create tracking plan", "define measurement strategy", "GTM strategy".
development
Pipeline status check for GTM projects. Use when returning to a project mid-implementation, when unsure what step comes next, or to get a quick overview of what has been completed. Reads all GTM output files and shows which skills have run, current implementation coverage, and the recommended next step. No API calls, instant. Trigger on - "what step am I on", "gtm status", "where did I leave off", "what's been done", "check progress", "pipeline status".
development
Automates Google Tag Manager API setup including googleapis installation, OAuth credential creation, token management, and prerequisites validation. Use when users need to "set up GTM API", "configure GTM API access", "get GTM OAuth credentials", "install googleapis", or encounter authentication errors. Handles complete technical setup from dependency installation through API connection verification.