Skip to main content
skill CX Codex

product-analytics · travisjneuman — Claude Code skill: what it does, how to install

product-analytics architects event tracking, funnels, cohorts, and privacy-compliant instrumentation for PostHog, Amplitude, Mixpanel, and Segment.

MIT 139 installs ★ 114 updated 2026-10-25

Install into Claude Code · Skills CLI (Vercel) All methods and platforms ↓
npx skills add travisjneuman/.claude --skill product-analytics -a claude-code
Open on GitHub

What product-analytics does

This skill guides the design and implementation of product telemetry. It establishes strict schema conventions following the object_action format in past tense (such as user_signed_up or project_deleted) to avoid fragmented analytics datasets.

The skill includes TypeScript implementations for structured event tracking, identity resolution with alias, and consent handling under GDPR or CCPA. Events queue in memory until tracking approval is granted, and session replay stays disabled until users opt in explicitly.

What it helps with

  • design type-safe event taxonomies before writing tracking code
  • build a PostHog wrapper with consent gating and event queuing
  • connect anonymous pre-signup sessions to authenticated user IDs
  • set up instrumentation schemas for onboarding funnels and experiments

Example prompts for the agent

  • Design an event tracking plan for our payment and subscription flow using PostHog
  • Create a typed analytics wrapper with consent state management in TypeScript
  • Help set up an onboarding funnel taxonomy following the object_action pattern

How to install product-analytics

1Skills CLI (Vercel)

npx skills add travisjneuman/.claude --skill product-analytics -a claude-code

2Manually: put the files in place

~/.claude/skills/product-analytics/SKILL.md

Copy the whole skill folder; for one project use .claude/skills/product-analytics/

Step by step, with commands for each platform: How to install skills in Claude Code: five ways

Questions about product-analytics

How to install product-analytics in Claude Code?

Run this command in your terminal: npx skills add travisjneuman/.claude --skill product-analytics -a claude-code.

What does the product-analytics skill do?

It equips the agent with guidelines and typed patterns for event tracking taxonomy, funnel design, cohort analysis, and SDK configuration across tools like PostHog and Amplitude.

Does the tracking setup handle privacy consent?

Yes, its client pattern defaults to pending consent, buffers incoming track calls in memory, and discards queued data if the user denies consent.

Source text

SKILL.md · MIT
---
name: product-analytics
description: Event tracking architecture, funnels, cohorts, A/B testing, PostHog/Amplitude. Use when designing event tracking, building funnels or cohorts, or instrumenting experiments.
---

# Product Analytics

## Overview

This skill covers designing and implementing product analytics systems that provide actionable insights into user behavior. It addresses event taxonomy design, analytics SDK integration with major platforms (PostHog, Amplitude, Mixpanel, Segment), funnel and cohort analysis, A/B testing and feature flags, user journey mapping, GDPR-compliant consent management, and custom metric definitions.

Use this skill when adding analytics to a new product, redesigning an event tracking system, setting up A/B testing infrastructure, implementing consent management, or building custom dashboards for product teams.

---

## Core Principles

1. **Design the taxonomy before writing code** - A well-designed event naming convention and property schema prevents the #1 analytics failure: inconsistent, unqueryable data. Agree on naming conventions first.
2. **Track actions, not pages** - Page views tell you where users went. Events with context tell you what users did and why. Focus on user actions: `project_created`, `file_uploaded`, `subscription_upgraded`.
3. **Identify before you track** - Every event needs a user identity. Anonymous events before signup should be linked to the authenticated identity once the user logs in (alias/merge).
4. **Consent is mandatory** - GDPR and CCPA require explicit user consent before tracking. Build consent management into the analytics layer, not as an afterthought.
5. **Less is more** - Tracking everything creates noise. Track the events that answer specific product questions. You can always add events later; removing noise from existing data is much harder.

---

## Key Patterns

### Pattern 1: Event Taxonomy Design

**When to use:** Before implementing any analytics tracking. This is the foundation everything else builds on.

**Implementation:**

```typescript
// Event taxonomy schema
// Convention: object_action (noun_verb in past tense)

// Core event types
type AnalyticsEvent =
  // Authentication
  | { event: "user_signed_up"; properties: { method: "email" | "google" | "github"; referralSource?: string } }
  | { event: "user_logged_in"; properties: { method: "email" | "google" | "github" } }
  | { event: "user_logged_out"; properties: Record<string, never> }

  // Onboarding
  | { event: "onboarding_started"; properties: { variant?: string } }
  | { event: "onboarding_step_completed"; properties: { step: number; stepName: string } }
  | { event: "onboarding_completed"; properties: { durationSeconds: number } }
  | { event: "onboarding_skipped"; properties: { lastStep: number } }

  // Core product actions
  | { event: "project_created"; properties: { template?: string; source: "dashboard" | "onboarding" | "api" } }
  | { event: "project_deleted"; properties: { projectAge: number; itemCount: number } }
  | { event: "file_uploaded"; properties: { fileType: string; fileSizeBytes: number; source: "drag_drop" | "file_picker" | "api" } }

  // Subscription
  | { event: "subscription_started"; properties: { plan: string; billingCycle: "monthly" | "annual"; amount: number } }
  | { event: "subscription_upgraded"; properties: { fromPlan: string; toPlan: string } }
  | { event: "subscription_cancelled"; properties: { reason?: string; plan: string; tenureDays: number } }

  // Feature engagement
  | { event: "feature_used"; properties: { feature: string; context: string } }
  | { event: "search_performed"; properties: { query: string; resultCount: number; source: string } }
  | { event: "export_completed"; properties: { format: "csv" | "pdf" | "json"; itemCount: number } };

// Type-safe tracking function
function track<T extends AnalyticsEvent>(
  event: T["event"],
  properties: T["properties"]
): void {
  // Implementation below
}

// Usage - fully typed, autocomplete works
track("project_created", {
  template: "blank",
  source: "dashboard",
});
```

**Why:** A typed event taxonomy prevents typos (`user_signedup` vs `user_signed_up`), ensures required properties are always present, and makes the tracking plan self-documenting. The `object_action` convention groups related events together in analytics dashboards.

---

### Pattern 2: Analytics Client with Consent Management

**When to use:** Every product that tracks user behavior, which is every product.

**Implementation:**

```typescript
// analytics.ts - Unified analytics client
import posthog from "posthog-js";

type ConsentStatus = "granted" | "denied" | "pending";

interface AnalyticsConfig {
  posthogKey: string;
  posthogHost?: string;
}

class Analytics {
  private initialized = false;
  private consent: ConsentStatus = "pending";
  private queuedEvents: Array<{ event: string; properties: Record<string, unknown> }> = [];

  init(config: AnalyticsConfig) {
    posthog.init(config.posthogKey, {
      api_host: config.posthogHost ?? "https://us.i.posthog.com",
      persistence: "localStorage+cookie",
      autocapture: false, // Explicit tracking only
      capture_pageview: false, // Manual pageview tracking
      capture_pageleave: true,
      disable_session_recording: true, // Replay only after explicit consent, with inputs masked (CIPA wiretap / GDPR)
      // Respect Do Not Track
      respect_dnt: true,
      // Cookie-less mode until consent
      persistence: this.consent === "granted" ? "localStorage+cookie" : "memory",
    });
    this.initialized = true;
  }

  setConsent(status: ConsentStatus) {
    this.consent = status;

    if (status === "granted") {
      posthog.opt_in_capturing();
      // Flush queued events
      for (const event of this.queuedEvents) {
        this.trackInternal(event.event, event.properties);
      }
      this.queuedEvents = [];
    } else if (status === "denied") {
      posthog.opt_out_capturing();
      this.queuedEvents = [];
    }
  }

  identify(userId: string, traits?: Record<string, unknown>) {
    if (this.consent !== "granted") return;
    posthog.identify(userId, traits);
  }

  // Alias anonymous ID to authenticated ID (for signup flow)
  alias(newId: string) {
    if (this.consent !== "granted") return;
    posthog.alias(newId);
  }

  track(event: string, properties?: Record<string, unknown>) {
    if (this.consent === "denied") return;

    const enrichedProperties = {
      ...properties,
      timestamp: new Date().toISOString(),
      url: typeof window !== "undefined" ? window.location.href : undefined,
      referrer: typeof document !== "undefined" ? document.referrer : undefined,
    };

    if (this.consent === "pending") {
      this.queuedEvents.push({ event, properties: enrichedProperties });
      return;
    }

    this.trackInternal(event, enrichedProperties);
  }

  private trackInternal(event: string, properties: Record<string, unknown>) {
    if (!this.initialized) return;
    posthog.capture(event, properties);
  }

  page(name?: string, properties?: Record<string, unknown>) {
    this.track("$pageview", { pageName: name, ...properties });
  }

  reset() {
    posthog.reset();
  }
}

export const analytics = new Analytics();
```

```tsx
// React consent banner component
function ConsentBanner() {
  const [showBanner, setShowBanner] = useState(() => {
    return localStorage.getItem("analytics_consent") === null;
  });

  const handleConsent = (granted: boolean) => {
    const status = granted ? "granted" : "denied";
    localStorage.setItem("analytics_consent", status);
    analytics.setConsent(status);
    setShowBanner(false);
  };

  if (!showBanner) return null;

  return (
    <div role="dialog" aria-label="Cookie consent" className="consent-banner">
      <p>We use analytics to improve our product. No personal data is sold.</p>
      <div className="consent-actions">
        <button onClick={() => handleConsent(false)}>Decline</button>
        <button onClick={() => handleConsent(true)}>Accept</button>
      </div>
    </div>
  );
}
```

**Why:** Consent-first analytics is legally required (GDPR, CCPA) and builds user trust. The queue pattern ensures no events are lost if the user grants consent after performing actions. Explicit tracking (no autocapture) keeps data clean and intentional.

---

### Pattern 3: Funnel Analysis Implementation

**When to use:** Measuring conversion through multi-step flows (signup, onboarding, checkout).

**Implementation:**

```typescript
// Track each funnel step explicitly
const ONBOARDING_FUNNEL = [
  "onboarding_started",
  "onboarding_step_completed:profile",
  "onboarding_step_completed:workspace",
  "onboarding_step_completed:invite",
  "onboarding_completed",
] as const;

// Instrument each step
function OnboardingFlow() {
  const [currentStep, setCurrentStep] = useState(0);

  useEffect(() => {
    analytics.track("onboarding_started", { variant: "v2" });
  }, []);

  const completeStep = (stepName: string) => {
    analytics.track("onboarding_step_completed", {
      step: currentStep,
      stepName,
      timeOnStepSeconds: getTimeOnStep(),
    });
    setCurrentStep((prev) => prev + 1);
  };

  const skip = () => {
    analytics.track("onboarding_skipped", {
      lastStep: currentStep,
      lastStepName: steps[currentStep].name,
    });
    router.push("/dashboard");
  };

  const complete = () => {
    analytics.track("onboarding_completed", {
      durationSeconds: getTotalDuration(),
      stepsCompleted: currentStep + 1,
      stepsSkipped: steps.length - currentStep - 1,
    });
    router.push("/dashboard");
  };

  // ...render steps
}

// Checkout funnel tracking
function useCheckoutFunnel() {
  const trackStep = (step: string, properties?: Record<string, unknown>) => {
    analytics.track(`checkout_${step}`, {
      ...properties,
      cartValue: getCartTotal(),
      itemCount: getCartItemCount(),
      timestamp: Date.now(),
    });
  };

  return {
    viewCart: () => trackStep("cart_viewed"),
    startCheckout: () => trackStep("started"),
    addShipping: (method: string) => trackStep("shipping_added", { method }),
    addPayment: (type: string) => trackStep("payment_added", { type }),
    complete: (orderId: string) => trackStep("completed", { orderId }),
    abandon: (step: string) => trackStep("abandoned", { lastStep: step }),
  };
}
```

**Why:** Funnel analysis reveals where users drop off. Tracking each step with context (time spent, variant, cart value) enables segmented analysis: "Users from Google Ads drop off at the shipping step 3x more than organic users." This insight drives targeted optimization.

---

### Pattern 4: Feature Flag-Driven A/B Testing

**When to use:** Testing product changes with statistical rigor before rolling out to all users.

**Implementation:**

```typescript
// PostHog feature flags for A/B testing
import posthog from "posthog-js";

// Check feature flag with typed variants
function useExperiment<T extends string>(
  flagKey: string,
  variants: T[]
): T | "control" | undefined {
  const [variant, setVariant] = useState<T | "control" | undefined>();

  useEffect(() => {
    posthog.onFeatureFlags(() => {
      const value = posthog.getFeatureFlag(flagKey);

      if (value === false || value === undefined) {
        setVariant("control");
      } else if (typeof value === "string" && variants.includes(value as T)) {
        setVariant(value as T);
      } else {
        setVariant("control");
      }

      // Track experiment exposure (for accurate analysis)
      analytics.track("$experiment_started", {
        experiment: flagKey,
        variant: value ?? "control",
      });
    });
  }, [flagKey]);

  return variant;
}

// Usage in component
function PricingPage() {
  const variant = useExperiment("pricing-page-redesign", ["new-layout", "social-proof"]);

  if (!variant) return <LoadingSkeleton />;

  switch (variant) {
    case "new-layout":
      return <PricingNewLayout />;
    case "social-proof":
      return <PricingSocialProof />;
    case "control":
    default:
      return <PricingControl />;
  }
}
```

**Why:** A/B testing removes opinion from product decisions. Feature flags enable gradual rollout, instant rollback, and segment-specific targeting. Tracking exposure events separately from conversion events ensures accurate statistical analysis (intent-to-treat analysis).

---

## Event Naming Convention Reference

| Convention | Example | When to Use |
|---|---|---|
| `object_action` | `project_created`, `file_uploaded` | Standard product events |
| `$system_event` | `$pageview`, `$identify` | System/platform events |
| `experiment_*` | `$experiment_started` | A/B test tracking |
| `feature_used` | `feature_used { feature: "export" }` | Generic feature engagement |

---

## Anti-Patterns

| Anti-Pattern | Why It's Bad | Better Approach |
|---|---|---|
| Autocapture everything | Noisy data, hard to query, privacy risk | Explicit event tracking with defined taxonomy |
| Inconsistent event names | `userSignedUp` vs `user_signed_up` vs `signup` | Enforce naming convention with TypeScript types |
| Tracking without consent | GDPR/CCPA violation, fines up to 4% revenue | Consent banner with queue pattern |
| No user identification | Cannot do cohort analysis or retention | Identify users on login, alias on signup |
| Tracking PII in event properties | Privacy violation, data retention issues | Use user IDs, not emails/names in event properties |
| One massive "user_action" event | Cannot create meaningful funnels | Specific event per meaningful action |
| Not tracking negative outcomes | Only see what works, not what fails | Track errors, abandonment, rage clicks |

---

## Checklist

- [ ] Event taxonomy documented and typed (TypeScript interface)
- [ ] Naming convention enforced (`object_action` pattern)
- [ ] Analytics client initialized with consent management
- [ ] User identification on login, alias on signup
- [ ] Funnel steps tracked with contextual properties
- [ ] Feature flags set up for A/B testing
- [ ] Experiment exposure events tracked separately from conversions
- [ ] GDPR consent banner implemented with queue pattern
- [ ] No PII in event properties (emails, full names, IPs)
- [ ] Key funnels visualized in analytics dashboard
- [ ] Retention cohorts configured (Day 1, Day 7, Day 30)
- [ ] Analytics events validated in development (debug mode)

---

## Related Resources

- **Skills:** `growth-engineering` (A/B testing infrastructure), `authentication-patterns` (identify/alias flow)
- **Skills:** `accessibility-a11y` (accessible consent banners)
- **Rules:** `docs/reference/stacks/react-typescript.md` (React hooks for analytics)

© travisjneuman · MIT · travisjneuman/.claude

Similar skills

All skills for Data and databases →

product-analytics by other authors comes first.

product-analytics Alireza Rezvani The product-analytics skill helps define product KPIs, shape metric dashboards, and read cohort, retention, and feature adoption data. CX Codex +1 684installs product-analytics OrchestKit The product-analytics skill evaluates A/B tests, cohort retention, and funnels. It helps explain adoption changes, conversion losses, and experiment outcomes. CX Codex +1 120installs product-analytics daffy0208 Lays out product analytics: picking a North Star metric, mapping a signup funnel, comparing cohorts and marking user actions as events. CX Codex +1 244installs product-analytics Paweł Huryn The product-analytics Claude Code skill configures behavioral analytics without analytics cookies. It activates for work involving Clarity or PostHog, session recordings, or heatmaps. CX Codex +1 ★ 741repo stars product-analytics-setup rampstackco product-analytics-setup — a skill for instrumenting product analytics correctly through clean event taxonomies, property schemas, and funnels. It prevents untrusted metrics when shipping features. CX Codex +1 285installs analytics coreyhaines31 analytics — a skill for Claude Code that structures tracking plans and audits metric calculations. Standardizes event naming across GA4, GTM, Mixpanel, and PostHog. CX Codex +1 97,200installs analytics-skills clamp-sh analytics-skills — a set of agent skills that has Claude diagnose traffic swings, judge channel and funnel quality, and read A/B tests without the usual rookie mistakes. ★ 10repo stars Engageable Analytics engageable-tech Engageable Analytics is an MCP server for Claude Code: your agent pulls data from GA4, Mixpanel, and PostHog and runs metric analysis. CX Codex +1 ★ 1repo stars instrument-product-analytics PostHog The instrument-product-analytics Claude Code skill adds PostHog events to product code. Run it after building a feature or reviewing a PR; it can also set up the SDK when the project lacks it. CX Codex +1 912installs signals-scout-product-analytics PostHog signals-scout-product-analytics — a skill for Claude Code and Codex monitoring core product analytics flows in PostHog. Detects derived-rate regressions across funnels and retention while entrant volume holds steady. CX Codex +1 204installs

From the same set117

The whole set →
newsletter-creator newsletter-creator builds a company newsletter from a fixed outline: section order, a scoring pass over the links, and email layout rules to follow. CX Codex +1 140installs generic-react-feature-developer generic-react-feature-developer is a Claude Code skill that defines React feature architecture, including directory layout, Zustand, React Query, IndexedDB, and lazy loading. CX Codex +1 139installs svelte-development The svelte-development Claude Code skill covers Svelte 5 and SvelteKit development. It applies to reactive components, SvelteKit routing and server functions, and upgrades from Svelte 4. CX Codex +1 139installs llm-app-development llm-app-development — a skill for Claude Code guides the design of RAG pipelines, autonomous agents, and structured schemas. Triggers when building chatbots, retrieval systems, or LLM-driven tools. CX Codex +1 139installs payment-integration The payment-integration skill covers Stripe and RevenueCat integrations, subscription flows, and webhook handling. Use it when building payments or reviewing PCI scope. CX Codex +1 139installs generic-static-feature-developer generic-static-feature-developer guides feature work on plain HTML, CSS and JS sites: vanilla patterns, a GitHub Actions deploy and checks before you commit. CX Codex +1 139installs customer-success customer-success guides engineering workflows for customer support systems, knowledge bases, ticketing integrations, and health metrics. CX Codex +1 138installs test-specialist test-specialist — a Claude Code skill that supplies test patterns for JS/TS, Python, Go, and Rust. Activates only when you explicitly ask for tests or coverage targets. CX Codex +1 138installs

Project sponsors

Companies that keep this analytics open