skills/gtm-dom-standardization/SKILL.md
Standardizes all click-related IDs and CSS classes across website for clean analytics tracking. Use when users want to "standardize analytics classes", "clean up tracking IDs", "prepare DOM for GTM", "fix analytics naming", or "make tracking consistent". Scans entire codebase (HTML/JSX/TSX/Vue) and applies consistent naming convention - IDs as "cta_{location}_{action}" and classes as "js-track js-{category} js-{action} js-{location}". Acts as senior frontend engineer ensuring scalable GA4/GTM implementation.
npx skillsauth add aimonk2025/google-tag-manager-automation gtm-dom-standardizationInstall 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 standardize all DOM identifiers (IDs and CSS classes) across the codebase to create a clean, consistent foundation for analytics tracking.
Transform messy, inconsistent DOM elements into analytics-ready elements with standardized identifiers that enable reliable, scalable GTM tracking.
Pattern: {category}_{location}_{descriptor}
Categories: cta, nav, form, video, audio, download, outbound
Examples:
id="cta_hero_get_started"
id="nav_header_pricing"
id="form_footer_newsletter"
id="video_hero_product_demo"
id="outbound_footer_twitter"
Pattern: js-track js-{category} js-{action} js-{location}
Required: js-track (base class for all tracked elements)
Categories: cta, nav, form, pricing, auth, demo, outbound, media
Actions: click, submit, open, close, play, pause, download, expand
Locations: hero, header, footer, sidebar, modal, navbar, pricing
Examples:
class="js-track js-cta js-click js-hero"
class="js-track js-nav js-click js-header"
class="js-track js-form js-submit js-footer"
class="js-track js-media js-play js-hero"
Detect Framework
Identify Component Files
Element Discovery
<button> tags<a> tags (links)<Link> components (Next.js/React Router)<form> tags<video>, <audio> tagsFor each element, determine the appropriate category:
CTA (Call-to-Action):
Navigation:
Form:
<form> tag, input fields, submit buttonsPricing:
Auth:
Demo:
Outbound:
Media:
<video>, <audio> tagsUse these decision trees for ambiguous elements:
"Learn More" Button:
Is it the primary CTA on the page?
├─ Yes → Category: cta
└─ No → Category: nav
"Contact Us" Element:
Where is it located?
├─ In navbar/footer → Category: nav
├─ Hero or prominent → Category: cta
└─ Content area → Category: cta (default)
"Watch Demo" Button:
Is it a primary conversion action?
├─ Yes → Category: demo (primary: cta + demo)
└─ No → Category: demo
Form Submit Button:
Is it inside a <form> tag?
├─ Yes → Category: form, Action: submit
└─ No → Category: cta, Action: click
When in doubt: Default to the category with highest business impact (cta > form > nav)
For each element, apply standardized identifiers:
Before (Generic Button):
<button class="btn primary">Get Started</button>
After (Analytics-Ready):
<button
className="btn primary js-track js-cta js-click js-hero"
id="cta_hero_get_started"
>
Get Started
</button>
Before (Plain Link):
<a href="/pricing">Pricing</a>
After (Analytics-Ready):
<a
href="/pricing"
className="js-track js-nav js-click js-header"
id="nav_header_pricing"
>
Pricing
</a>
Before (Next.js Link):
<Link href="/pricing">Pricing</Link>
After (Analytics-Ready):
<Link
href="/pricing"
className="js-track js-nav js-click js-header"
id="nav_header_pricing"
>
Pricing
</Link>
Before (Form):
<form onSubmit={handleSubmit}>
<input type="email" />
<button type="submit">Subscribe</button>
</form>
After (Analytics-Ready):
<form
onSubmit={handleSubmit}
className="js-track js-form js-submit js-footer"
id="form_footer_newsletter"
>
<input type="email" />
<button type="submit">Subscribe</button>
</form>
React/Next.js:
// Use className (not class)
<button
className="btn primary js-track js-cta js-click js-hero"
id="cta_hero_get_started"
>
Get Started
</button>
Vue:
<!-- Use :class for dynamic classes -->
<button
:class="['btn', 'primary', 'js-track', 'js-cta', 'js-click', 'js-hero']"
id="cta_hero_get_started"
>
Get Started
</button>
HTML:
<button
class="btn primary js-track js-cta js-click js-hero"
id="cta_hero_get_started"
>
Get Started
</button>
CRITICAL RULE: NEVER remove existing visual styling classes.
Analytics classes are ADDITIVE. Always append, never replace.
Wrong:
// ❌ Removed original classes
<button className="js-track js-cta js-click">
Get Started
</button>
Right:
// ✅ Preserved original classes
<button className="btn btn-lg btn-primary rounded shadow js-track js-cta js-click js-hero">
Get Started
</button>
After standardization, verify:
Generate a detailed summary for the user:
=== DOM Standardization Complete ===
Updated 47 elements across 12 files
--- Element Breakdown ---
✓ 12 CTAs standardized
✓ 8 navigation links updated
✓ 3 forms with tracking classes
✓ 5 outbound links marked
✓ 2 media elements updated
✓ 17 existing elements renamed for consistency
--- Categories Used ---
cta (12), nav (8), form (3), outbound (5), media (2)
--- Files Modified ---
app/page.tsx (12 elements)
components/Navbar.tsx (8 elements)
components/Footer.tsx (7 elements)
components/Hero.tsx (6 elements)
components/PricingSection.tsx (4 elements)
... (7 more files)
--- Naming Decisions ---
Ambiguous cases resolved:
1. "Learn More" button (app/page.tsx:156)
→ Categorized as: CTA (primary action in section)
→ Applied: class="js-track js-cta js-click js-features"
2. "Contact Us" link (components/Navbar.tsx:45)
→ Categorized as: Navigation (in navbar)
→ Applied: class="js-track js-nav js-click js-header"
3. "Watch Demo" button (app/page.tsx:89)
→ Categorized as: Demo + CTA
→ Applied: class="js-track js-demo js-click js-hero"
--- Before vs After Examples ---
Before:
<button class="btn primary">Get Started</button>
After:
<button
className="btn primary js-track js-cta js-click js-hero"
id="cta_hero_get_started"
>
Get Started
</button>
--- Validation ---
✓ All original styling classes preserved
✓ No visual changes to site
✓ Consistent naming across all files
✓ Framework syntax correct (className for React)
--- Next Steps ---
✓ DOM is now analytics-ready
→ Next: Invoke gtm-strategy to plan what to track
→ Then: Invoke gtm-implementation to add dataLayer events
Ready to plan your tracking strategy? Invoke gtm-strategy skill.
Next.js:
className (not class)React:
className (not class)Vue:
:class or class appropriately❌ Removing visual classes:
// WRONG
<button className="js-track js-cta js-click">
✅ Preserving visual classes:
// RIGHT
<button className="btn btn-primary js-track js-cta js-click">
❌ Inconsistent patterns:
// WRONG - mixed patterns
<button id="heroGetStarted" class="cta-button track-click">
<button id="footer_signup" class="js-cta">
✅ Consistent patterns:
// RIGHT - same pattern
<button id="cta_hero_get_started" className="js-track js-cta js-click js-hero">
<button id="cta_footer_signup" className="js-track js-cta js-click js-footer">
❌ Missing js-track base class:
// WRONG
<button className="js-cta js-click">
✅ Including js-track:
// RIGHT
<button className="js-track js-cta js-click">
Quick reference for common elements:
| Element | Category | Example Classes | |---------|----------|-----------------| | "Get Started" button | cta | js-track js-cta js-click js-hero | | "Pricing" nav link | nav | js-track js-nav js-click js-header | | Newsletter form | form | js-track js-form js-submit js-footer | | "Choose Pro" pricing CTA | pricing | js-track js-pricing js-click js-pricing | | Login button | auth | js-track js-auth js-click js-header | | "Watch Demo" button | demo | js-track js-demo js-click js-hero | | Twitter link | outbound | js-track js-outbound js-click js-footer | | Product video | media | js-track js-media js-play js-hero |
references/element-patterns.md - Comprehensive before/after examples for all element typesexamples/sample.md - Example standardization output showing before/after code changes and naming convention tableBefore completing standardization:
Q: Should every button get an ID? A: No. Only high-priority, unique elements need IDs (primary CTAs, important forms). All elements should have classes.
Q: What if an element already has analytics classes? A: Update them to match the standard pattern. Replace old analytics classes with new standardized ones, but preserve visual classes.
Q: How do I categorize a "Learn More" button?
A: If it's a primary action on the page → cta. If it's a secondary navigation link → nav. When in doubt, choose cta.
Q: Should I standardize elements in node_modules? A: No. Only standardize files in your codebase (app/, components/, pages/, src/). Never modify third-party code.
Q: What if the framework uses custom components?
A: Apply the same pattern. Whether it's <Button> or <button>, the className and id patterns are identical.
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.