google-analytics-v4
Implements privacy-compliant event tracking with Google Analytics 4. Use when wiring analytics that must comply with GDPR/CCPA via Consent Mode V2 — `snake_case` event names, no PII to GA servers, GTM-driven event firing, and DebugView verification before deploy.
- License 许可
- MIT
- 最近更新
- 2026-05-27
- Stars
- ★ 0
- Forks
- 0
01 前言 Front Matter
- name
- google-analytics-v4
- vendor
- description
- Implements privacy-compliant event tracking with Google Analytics 4. Use when wiring analytics that must comply with GDPR/CCPA via Consent Mode V2 — `snake_case` event names, no PII to GA servers, GTM-driven event firing, and DebugView verification before deploy.
03 SKILL.md 正文
Skill: Google Analytics 4 (GA4)
Policy Capsule
- Implement Consent Mode V2 and respect GDPR/CCPA; never send PII to GA servers.
- Track meaningful business actions (e.g.
start_checkout,share_article) rather than relying solely on page views. - Use
snake_casefor every event name and parameter — GA4 enforces this convention. - Fire all events through Google Tag Manager rather than embedding measurement IDs directly in application code.
- Define critical user attributes (e.g.
user_type,pricing_plan) as custom dimensions on the GA4 property. - Verify every new event in GA4 DebugView before deploying to production.
- Filter development and internal traffic out of the production GA4 property.
- Keep IP anonymization enabled and configure cross-domain tracking when traffic spans multiple origins.
Guidelines for privacy-compliant and data-driven event tracking using GA4.
1. Core Principles
- Privacy Compliance: Adhere to GDPR and CCPA. Implement Consent Mode V2 and never send PII to GA servers.
- Event-Driven: Focus on meaningful user actions (e.g., "start_checkout", "share_article") rather than just page views.
- Data Accuracy: Filter out development and internal traffic from production property data.
2. Technical Standards
- GTM Integration: Use Google Tag Manager for event firing to decouple marketing tags from core application code.
- Custom Dimensions: Define critical data points (e.g.,
user_type,pricing_plan) as custom dimensions in the GA4 property. - Enhanced Measurement: Leverage GA4's built-in tracking for scrolls, outbound clicks, and site searches.
3. Best Practices
- Naming Convention: Use
snake_casefor event names and parameters. - Debug View: Use the GA4 DebugView in the browser to verify events fire correctly before deploying.
- Anonymization: Ensure IP anonymization is enabled (default in GA4) and cross-domain tracking is configured if necessary.
04 同仓库更多 Skills
no-capsule-skill
Fixture without a Policy Capsule section.
backend-security-patterns
Combined backend protocols for authentication (Clerk JWT verification) and PII-safe observability. Use when handling auth on the server, verifying Clerk webhooks via `svix`, scoping metadata via `publicMetadata`/ `privateMetadata`, or sanitizing logs to keep emails, tokens, and request bodies out of telemetry.
vitest
Writes fast, isolated unit and integration tests with Vitest. Use when each test must run on file-save without shared state — `vi.mock()` for external deps, `vi.spyOn()` for call monitoring, AAA structure, and edge-case coverage for null/undefined/boundary inputs.
playwright
Robust E2E browser testing with Playwright. Use when writing browser-driven tests — leverage auto-waiting (no `waitForTimeout`), prefer user-visible locators (`getByRole`, `getByText`, `getByLabel`) over CSS/XPath, reuse `storageState` for auth, and enable trace-on-first-retry for CI debugging.
playwright-bdd
Wires Gherkin `.feature` files to Playwright via the `playwright-bdd` library. Use when running BDD scenarios on a Playwright runtime — pairs with the `gherkin-authoring` skill (scenario prose) and the `playwright` skill (browser conventions). Drives execution by tag expression with trace-first debugging and Playwright-native sharding.
lighthouse-baseline
Codifies the capture-and-check baseline pattern for long-running quality signals (Lighthouse scores, bundle size, p95 latency, runtime memory). Use when wiring a new metric that needs a baseline file, paired :capture / :check npm scripts, a tolerance-bounded gate, and a weekly refresh cadence — the goal is a hard CI signal that ratchets only with intent.