---
name: analytics-tracking-setup
description: "Use when setting up or auditing analytics tracking: GA4, GTM, event naming, UTM conventions, tracking plans, and validating that events fire."
---
# Analytics Tracking
## What this does
Helps decide what to measure and how to implement it in GA4, GTM or similar tools. It produces a tracking plan or an audit checklist of what's broken.
## When to use
Use for "set up tracking", GA4, event tracking, UTM parameters, tag manager, tracking plans, "are my events firing", or "how do I measure this".
## How to run it
1. If a product marketing context file exists (`.agents/product-marketing.md` or `.claude/product-marketing.md`), read it first.
2. Ask only what's missing: tools in use, key actions to track, decisions the data will inform, who implements, privacy/consent needs, and what's already tracked.
3. Apply the principles below, then deliver the tracking plan.
**Principles**
- Track for decisions, not data. Start from the questions and work backwards.
- Name things consistently and document them.
- Clean data beats more data. Validate.
- Compute, don't eyeball: derive totals and rates with a script or spreadsheet, and cross-check headline figures a second way.
- Rate metrics divide numerator and denominator over the same closed window. Pending cohorts are excluded and labeled, not counted as failures.
- Argue recommendations from the user's stated goal and say what each option trades away.
**Naming**
- Object-action, lowercase with underscores: `signup_completed`, `cta_hero_clicked`.
- Put context in properties, not the event name. No PII in properties.
- Keep provider-defined names for automatic or recommended events (e.g. GA4 `sign_up`, `purchase`) and map internal names explicitly.
**Essential events**
- Marketing site: cta_clicked (button_text, location), form_submitted (form_type), signup_completed (method, source), demo_requested.
- Product: onboarding_step_completed, feature_used, purchase_completed (plan, value), subscription_cancelled (reason).
**GA4 quick setup**: create property and data stream, install gtag.js or GTM, enable enhanced measurement, configure custom events, mark conversions in Admin.
**GTM data layer pattern**
javascript
dataLayer.push({
'event': 'form_submitted',
'form_name': 'contact',
'form_location': 'footer'
});
**UTM rules**: lowercase everything, hyphens between words, one spelling per source, no personal data, short but specific values, and test the final live URL. For partner links, use utm_medium for the deal type (newsletter, creator, podcast, affiliate, community) and utm_source for who sent the traffic. Use one link per placement. Create a custom GA4 channel group, because default grouping sends these mediums to Unassigned.
**Validation checklist**
- [ ] Events fire on the correct triggers
- [ ] Property values populate
- [ ] No duplicate events
- [ ] Works across browsers and mobile
- [ ] Conversions recorded correctly
- [ ] No PII leaking
Test with GA4 DebugView, GTM Preview Mode, and Tag Assistant. For privacy, use consent mode, collect only what's needed, and respect EU/UK/CA consent rules.
## Output
A tracking plan document:
markdown
# {Site/Product} Tracking Plan
## Overview
- Tools: {tools}
- Last updated: {date}
## Events
| Event Name | Description | Properties | Trigger |
## Custom Dimensions
| Name | Scope | Parameter |
## Conversions
| Conversion | Event | Counting |
For an audit, hand back a prioritized list of issues instead.
## Credit
Based on public content by coreyhaines31, packaged by Orbit.