# Analytics Tracking — Marketing Skill for AI Agents

Set up analytics backwards from decisions. List the questions you need answered, then track only the events that change an action. Name events object-action in lowercase with underscores (signup_completed, feature_used, subscription_upgraded), and put context in properties, not the event name. Where GA4 has a recommended or automatic event like sign_up or purchase, keep its name and map your internal name to it explicitly. Push events through a GTM data layer, register properties you want to segment by as custom dimensions, and mark key conversions in Admin with the right counting method. Validate in GA4 DebugView and GTM Preview before publishing. Keep PII out of events and UTMs, wait for consent where required, and compute every rate from matching, closed time windows.

> Maintained by Corey Haines · v2.2.7 · Updated 2026-11-19

Install: `npx skills add coreyhaines31/marketingskills`
Source: https://github.com/coreyhaines31/marketingskills/tree/main/skills/analytics

## How it works

1. **Start from the decisions** — The agent reads your product marketing context, then asks what decisions the data will inform, what counts as a key conversion, what's already tracked, which tools and stack you use, who implements it, and what privacy rules apply. Events that don't feed a decision are left out, since clean data beats more data.
2. **Draft the tracking plan** — It writes a plan with event name, description, properties and trigger, drawing on an event library for marketing sites, product onboarding and usage, monetization, and B2B team, integration and account events. Funnels are laid out as ordered sequences, for example pricing_viewed, plan_selected, checkout_started, payment_info_entered, purchase_completed.
3. **Set naming and property standards** — Events follow object-action naming, specific enough to read on their own (cta_hero_clicked rather than button_clicked). Standard properties cover page, user, account, plan and campaign context. GTM assets follow a Type, Description, Detail convention such as "GA4 - Event - Signup Completed" so containers stay readable.
4. **Implement in GA4 and GTM** — It writes the dataLayer pushes and gtag calls, sets user_id and user properties for logged-in users, and lists custom dimensions with the right scope (event, user or item). Conversions are marked with a counting method, once per session for signups and every event for purchases. Consent mode defaults storage to denied until the user opts in.
5. **Standardize UTMs and channels** — It sets UTM rules (lowercase, hyphens, one spelling per source, no personal data) and fixed patterns per partner type: newsletter, creator, podcast, affiliate and community. It adds GA4 custom channel groups so those mediums don't land in Unassigned, plus an "AI assistants" channel that captures assistant referrers as a floor, not the full effect.
6. **Validate and report correctly** — Before launch it runs the validation checklist: correct triggers, populated values, no duplicates, cross-browser and mobile, conversions recorded, no PII. In analysis it computes totals from row-level data, cross-checks each headline figure a second way, matches observation windows, and labels cohorts still inside their window as pending.

## When to use it

- "set up tracking"
- "GA4"
- "Google Analytics"
- "event tracking"
- "UTM parameters"
- "tag manager"
- "GTM"
- "analytics implementation"
- "tracking plan"
- "how do I measure this"

## What's inside

**The playbook covers:** Initial Assessment, Core Principles, Tracking Plan Framework, Event Naming Conventions, Essential Events, Event Properties, GA4 Implementation, Google Tag Manager, UTM Parameter Strategy, Debugging and Validation, Privacy and Compliance, Output Format, Overview, Events, Custom Dimensions, Conversions, Task-Specific Questions, Tool Integrations

### Reference library

- [Event Library Reference](https://github.com/coreyhaines31/marketingskills/blob/main/skills/analytics/references/event-library.md) — Comprehensive list of events to track by business type and context.
- [GA4 Implementation Reference](https://github.com/coreyhaines31/marketingskills/blob/main/skills/analytics/references/ga4-implementation.md) — Detailed implementation guide for Google Analytics 4.
- [Google Tag Manager Implementation Reference](https://github.com/coreyhaines31/marketingskills/blob/main/skills/analytics/references/gtm-implementation.md) — Detailed guide for implementing tracking via Google Tag Manager.

## Example

**Prompt:** Help me set up analytics tracking for our B2B SaaS product. We use GA4 and GTM. We need to track signups, feature usage, and upgrade events.

**Tracking plan (excerpt)**

Event                  | Properties                          | Trigger
sign_up (GA4 recommended; internal: signup_completed) | method, plan_type, source | account created (server-confirmed)
onboarding_step_completed | step_number, step_name           | each onboarding step
feature_used           | feature_name, feature_category      | in-app feature interaction
subscription_upgraded  | from_plan, to_plan, value, currency | upgrade payment succeeds

User properties: user_type (free/trial/paid), plan_type, account_id
Key events: sign_up (once per session), subscription_upgraded (every event)
No email, name or other PII in any parameter.

**GTM data layer push**

dataLayer.push({
  'event': 'subscription_upgraded',
  'from_plan': 'starter',
  'to_plan': 'pro',
  'value': 99,
  'currency': 'USD'
});

Tag: GA4 - Event - Subscription Upgraded
Trigger: Custom - subscription_upgraded
Fire the push only after the payment succeeds, not on the upgrade button click, so failed payments aren't counted.
Register from_plan and to_plan as event-scoped custom dimensions, and feature_name too, or they won't show in reports. Mark subscription_upgraded as a key event so it can be imported to Google Ads.

**Validation before publish**

1. GTM Preview: each trigger fires once per action, with no double fire from a second container.
2. GA4 DebugView (?debug_mode=true): parameters populate with the expected values.
3. Fire the upgrade from a test account and confirm one event, the correct value, and no email or name in any parameter.
4. Consent default set to denied for analytics_storage until the user opts in (EU/UK/CA).

## More things to ask

- What UTM parameters should we use? We run ads on Google, Meta, and LinkedIn, plus send a weekly newsletter and post on LinkedIn organically.
- our tracking seems broken — we're seeing duplicate events and our conversion numbers in GA4 don't match what our database shows. help?
- We're launching an e-commerce store and need to set up tracking from scratch. What events do we absolutely need?
- We need to make sure our tracking is GDPR compliant. We have European users and we're using GA4, Hotjar, and Facebook Pixel.
- Help me set up tracking for our A/B test. We want to measure which version of our pricing page converts better.

## FAQ

### How should I name analytics events?

Use object-action names in lowercase with underscores: signup_completed, form_submitted, cta_hero_clicked. Be specific, push context into properties instead of longer event names, avoid spaces and special characters, and document the convention before implementing. When a provider defines the event, such as GA4's sign_up, purchase, click or view_search_results, keep its name. A custom event named like an automatic one isn't collected automatically, so map internal names explicitly.

### What events should a B2B SaaS product track?

Cover the path from signup to revenue. That means signup_completed, onboarding_step_completed and first_key_action_completed for activation, and feature_used with feature_name and feature_category for usage. For revenue, track trial_started, subscription_upgraded with from_plan, to_plan and value, and subscription_cancelled with reason and tenure. B2B products should add team_member_invited, integration_connected and account-level events, plus user properties like user_type, plan_type and account_id to segment by.

### Why are my GA4 events not showing up?

Check DebugView first, then confirm the gtag or GTM tag is actually firing. Missing parameter values usually mean the custom dimension wasn't created, the parameter name doesn't match, or data is still processing, which can take 24–48 hours. Conversions that don't record are often not marked as conversions, have a mismatched event name, or use the wrong counting method. Duplicates usually come from two containers or a trigger firing twice.

### How should I structure UTM parameters?

Lowercase everything, since GA4 treats LinkedIn and linkedin as two sources. Use hyphens between words, one spelling per source, and never put emails, names or IDs in a UTM. For partners, utm_medium names the deal type (newsletter, creator, podcast, affiliate, community) and utm_source names who sent the traffic, with one link per placement. Then add a GA4 custom channel group, because most of those mediums otherwise fall into Unassigned.

### How do I track traffic from ChatGPT and other AI assistants?

You can't tag links an assistant puts in its answers. Some visits arrive with a referrer like chatgpt.com or perplexity.ai, or with an assistant-added utm_source. Create a GA4 channel group rule that collects known assistant referrers into an "AI assistants" channel and update it as new ones appear. Treat that channel as a floor. Many AI-influenced visits arrive later as direct or branded search with no referrer.

### Why do my conversion rates look wrong in reports?

Often the numerator and denominator cover different windows, for example a full month of spend divided by two weeks of conversions. Restate both over the weeks that actually have data. For cohort rates, only count cohorts whose observation window has closed, since a trial still inside its window is pending, not failed. Compute totals from row-level data with a script or spreadsheet, and cross-check each headline figure a second way.

## Related skills

- **ab-testing** — For experiment tracking
- **conversion-tracking** — For getting conversions (including GA4 key events from forms and bookings) to ad platforms and GA4, and verifying they arrive
- **attribution** — For attribution models, multi-touch/MMM/incrementality, and reconciling conflicting numbers across tools (once tracking is live)
- **seo-audit** — For organic traffic analysis
- **cro** — For conversion optimization (uses this data)
- **revops** — For pipeline metrics, CRM tracking, and revenue attribution

---
Canonical: https://marketing-skills.com/skills/analytics