Add, review, or update GA4 event tracking on HTML websites using data attributes and a reusable JavaScript tracker. Use when wiring gtag or GTM dataLayer events, choosing event names/parameters, or extending a base GA4 tracking snippet for clicks and simple interactions.
Scanned 2/12/2026
Install via CLI
openskills install majiayu000/claude-skill-registry---
name: ga4-event-tracking
description: Add, review, or update GA4 event tracking on HTML websites using data attributes and a reusable JavaScript tracker. Use when wiring gtag or GTM dataLayer events, choosing event names/parameters, or extending a base GA4 tracking snippet for clicks and simple interactions.
---
# GA4 Event Tracking
## Overview
Use this skill to instrument GA4 events in static HTML or simple web apps by attaching data attributes and a base JS tracker.
## Quick Start
1. Copy `assets/ga4-event-tracker.js` into the site (for example, `js/ga4-event-tracker.js`).
2. Load it after gtag or GTM (or at the end of `body`).
3. Add data attributes to elements you want to track.
4. Validate in GA4 DebugView.
### Example HTML
```html
<button
data-ga4-event="button_click"
data-ga4-label="hero_signup"
data-ga4-category="CTA"
data-ga4-params='{"link_text":"Start free trial","value":1,"currency":"USD"}'
>
Start free trial
</button>
```
## Common Tasks
### Add a tracked element
- Add `data-ga4-event` with a stable, action-based event name.
- Use `data-ga4-label` for human-readable context (button text or placement).
- Use `data-ga4-params` for extra GA4 parameters (JSON string).
### Extend the base tracker
- Add more event types (e.g., `submit`, `change`, `input`).
- Switch to event delegation for dynamic content.
- Add defaults (category, labels) based on element classes or containers.
- Add guardrails for invalid JSON in `data-ga4-params`.
### Apply naming conventions
- Use `references/ga4-event-naming.md` for event naming and parameter guidance.
- Prefer stable, language-agnostic event names and use labels for display text.
## Troubleshooting
- If `gtag` is not available, the tracker falls back to `dataLayer` for GTM.
- If neither gtag nor GTM is installed, events will not reach GA4.
- Add temporary console logs to confirm event payloads.
## Resources
### references/
- `references/ga4-event-naming.md`: Common GA4 event naming and parameters.
### assets/
- `assets/ga4-event-tracker.js`: Base GA4 tracking script to copy and extend.
No comments yet. Be the first to comment!
Use this skill when developing or maintaining browser extension code in the `browser/` directory, including Chrome/Firefox/Edge compatibility, content scripts, background scripts, or i18n updates.
SEO optimization with keyword analysis, readability assessment, technical validation, content quality. Use for search rankings, blog posts, content audits, or encountering keyword density, readability scores, meta tags, schema markup errors.
Python backend development expertise for FastAPI, security patterns, database operations, Upstash integrations, and code quality. Use when: (1) Building REST APIs with FastAPI, (2) Implementing JWT/OAuth2 authentication, (3) Setting up SQLAlchemy/async databases, (4) Integrating Redis/Upstash caching, (5) Refactoring AI-generated Python code (deslopification), (6) Designing API patterns, or (7) Optimizing backend performance.
Drive the full internationalization journey for a project — detect the stack, recommend a library, set up the chosen library, wrap existing strings, and optionally connect a translation platform. Use when the user asks to add or configure i18n, internationalization, localization, multi-language support, or translations — including when they explicitly mention LinguiJS, Lingui, next-intl, "wrap strings", "find hardcoded text", "make my app translatable", or "set up translations". Triggers on g...
PTES-aligned adversarial security audit for backend, frontend, and mobile applications. Produces a CVSS-scored Hacker Report with verified PoCs and phased remediation.