Back to Blog

data-analysis

The analytics Skill: Clean Event Tracking for Agents

A skill for GA4/PostHog event taxonomy, consent gating, and PII scrubbing—without charting or KPI fluff.

OpenAgentSkillPublished:

Where this fits

You're building an AI agent that adds analytics to a Next.js app. You need to track sign-ups, feature usage, and funnel steps—but you keep mixing up event names, double-counting page views, and forgetting to gate tracking behind consent. The analytics skill from the RSC Harness gives your agent a fixed workflow: taxonomy first, then SDK wiring, consent, PII scrubbing, and funnel validation. It stops your agent from drifting into charting or KPI territory, keeping it focused on the capture layer.

Why agents benefit

  • Produces a checkable event taxonomy before any code is written, so naming is consistent across teams.
  • Wires GA4 and PostHog SDKs correctly in the right files, with proper initialization and page-view hooks.
  • Gates every event behind a consent mode (e.g., denied until user opts in), avoiding legal headaches.
  • Scrubs PII automatically—emails, phone numbers, and user IDs are hashed or excluded before sending.
  • Validates funnels and flags double-counted events by checking for duplicate triggers and missing properties.

Practical scenarios

Instrumenting a new feature with GA4

Your agent adds a new "export report" button. Instead of guessing event names, it follows the taxonomy pattern: feature_export_clicked with properties format and source. It wires the GA4 event, adds a consent check, and ensures no user email leaks into the payload.

Fixing double-counted page views in PostHog

Your agent finds that page views are firing twice because both the router and a manual capture call exist. It deduplicates by removing the redundant call and adds a page_view filter to the SDK config.

Consent gating for EU visitors

The agent detects missing consent mode in PostHog. It adds a consent parameter that defaults to 'denied', and flips to 'granted' only after the user accepts. It also scrubs userId from initial events until consent is given.

Add it to your agent workflow

Install the skill with:

npx skills add ericrisco/rsc-harness --skill analytics

Then prompt your agent: "Instrument a custom pricing_viewed event in GA4, with consent gating and PII scrub." The agent will load the skill, produce the taxonomy, and generate the code changes.

Compare before adopting

Check the skill's GitHub repo for recent commits and open issues—fresh maintenance is a good sign. Compare it to writing your own instrumentation logic from scratch (which is error-prone) or using a generic "web analytics" skill that might also try to do charting. Ensure the skill's routing table matches your stack (Next.js, GA4/PostHog) and that it doesn't overlap with your existing KPI or dashboard skills.

Why it is worth tracking

The analytics skill has 58 stars and clear boundaries—it doesn't try to be everything. Its fixed workflow and checkable artifacts make it a reliable building block for agent-based analytics work. As more teams adopt agent-driven development, skills that enforce structure without scope creep will earn their place. Evaluate it when you next need to add tracking to a project, and see how it reduces double-counting and consent failures in your codebase. For more context, see the skill page.

Featured Skill

analytics

Skill by ericrisco