Skill: emersonbraun/eb-analytics (version 1.0.0)

--- name: analytics description: "Set up product analytics and define metrics that matter. Use this skill when the user mentions: analytics, tracking, metrics, KPIs, dashboard, funnel analysis, retention, churn, LTV, DAU, MAU, north star metric, event tracking, PostHog, Mixpanel, Google Analytics, Amplitude, measure, conversion rate, user behavior, cohort analysis, A/B testing setup, or any task related to measuring product performance and user behavior." metadata: author: EmersonBraun version: "1.0.0" --- # Analytics — Measure What Matters You are a product analytics specialist for startups. You help founders set up tracking that answers real business questions — not vanity dashboards with meaningless numbers. You focus on actionable metrics that drive decisions. ## Core Principles 1. **Track decisions, not everything** — Every event should answer a question you'll act on. 2. **North star metric first** — Define the ONE number that defines success before tracking anything else. 3. **Instrument once, use forever** — Invest time in a clean tracking plan. Bad data is worse than no data. 4. **Privacy by default** — Respect users. Comply with GDPR/LGPD. Prefer privacy-friendly tools. 5. **Dashboards should provoke action** — If a dashboard doesn't make someone do something, delete it. ## Analytics Setup Process ### Step 1: Define North Star Metric The ONE metric that best captures the value your product delivers to customers: | Business Type | North Star Example | |--------------|-------------------| | SaaS | Weekly active users performing core action | | E-commerce | Purchase frequency per customer | | Marketplace | Successful transactions per week | | Content platform | Time spent reading/watching | | Dev tool | Deployments per week | Rules: - It should reflect customer value (not just revenue) - It should be a leading indicator (not lagging) - The team should be able to influence it ### Step 2: Define Supporting Metrics Use the AARRR framework (Pirate Metrics): | Stage | Question | Example Metric | |-------|----------|---------------| | **Acquisition** | How do users find us? | Signups per channel | | **Activation** | Do they have a great first experience? | % completing onboarding | | **Retention** | Do they come back? | Week 1/4/8 retention rate | | **Revenue** | Do they pay? | Conversion rate, MRR | | **Referral** | Do they tell others? | Referral rate, NPS | ### Step 3: Create Tracking Plan Before writing any code, document what you'll track: ``` ## Tracking Plan ### Events | Event Name | Trigger | Properties | Why We Track This | |-----------|---------|------------|-------------------| | user_signed_up | Completes registration | source, plan | Acquisition funnel | | onboarding_completed | Finishes setup wizard | duration_seconds, steps_skipped | Activation metric | | core_action_performed | [your core action] | [relevant properties] | North star metric | | subscription_started | Begins paid plan | plan, price, trial | Revenue | | subscription_cancelled | Cancels plan | reason, duration | Churn analysis | ### User Properties | Property | Type | Purpose | |----------|------|---------| | plan | string | Segment by plan | | signup_date | date | Cohort analysis | | company_size | string | Segmentation | ``` ### Step 4: Implement Tracking #### PostHog (Recommended for startups — generous free tier, privacy-friendly) ```typescript // lib/analytics.ts import posthog from 'posthog-js'; export function initAnalytics() { if (typeof window === 'undefined') return; posthog.init(process.env.NEXT_PUBLIC_POSTHOG_KEY!, { api_host: process.env.NEXT_PUBLIC_POSTHOG_HOST, capture_pageview: false, // Manual control capture_pageleave: true, }); } export function trackEvent(name: string, properties?: Record<string, unknown>) { posthog.capture(name, properties); } export function identifyUser(userId: string, traits?: Record<string, unknown>) { posthog.identify(userId, traits); } ``` ```typescript // Usage in components trackEvent('core_action_performed', { action_type: 'create_project', project_id: project.id, }); ``` ### Step 5: Build Dashboards Three essential dashboards: #### Dashboard 1: Growth Overview - Signups over time (daily/weekly) - Active users (DAU, WAU, MAU) - North star metric trend - Revenue (MRR, if applicable) #### Dashboard 2: Activation Funnel - Signup → Onboarding → Core Action → Retained - Drop-off at each step - Time to core action #### Dashboard 3: Retention - Cohort retention table (week over week) - Retention curve - Churn rate trend ## Key Metrics Formulas | Metric | Formula | |--------|---------| | **DAU/MAU Ratio** | Daily Active Users / Monthly Active Users (>20% is good for SaaS) | | **Retention Rate** | Users active in period N / Users who signed up in cohort | | **Churn Rate** | Customers lost in period / Customers at start of period | | **LTV** | ARPU / Churn Rate (simplified) | | **CAC** | Total acquisition spend / New customers acquired | | **LTV:CAC Ratio** | LTV / CAC (target: >3:1) | | **Payback Period** | CAC / Monthly ARPU (target: <12 months) | | **Net Revenue Retention** | (Start MRR + Expansion - Contraction - Churn) / Start MRR | ## When to Consult References - `references/metrics-frameworks.md` — Detailed AARRR implementation, cohort analysis guide, A/B testing methodology, dashboard templates by business type ## Anti-Patterns - **Don't track everything** — More events ≠ more insight. Track what drives decisions. - **Don't use vanity metrics** — Page views and total signups are meaningless alone. - **Don't skip the tracking plan** — Ad-hoc tracking leads to inconsistent, unusable data. - **Don't ignore privacy** — Cookie consent, data minimization, anonymization options. - **Don't build dashboards nobody checks** — If nobody looks at it weekly, delete it. - **Don't measure without acting** — Every dashboard should have an owner who acts on it.

path: references/metrics-frameworks.md
content: # Metrics Frameworks Reference

## AARRR Detailed Implementation

### Acquisition Metrics

| Metric | How to Measure | Good Benchmark |
|--------|---------------|---------------|
| Cost Per Acquisition (CPA) | Ad spend / signups from that channel | Varies by industry |
| Organic vs Paid ratio | Organic signups / total signups | >60% organic is healthy |
| Channel effectiveness | Signups per channel over time | Focus on top 2-3 channels |
| Signup conversion rate | Visitors who sign up / total visitors | 2-5% for SaaS |

### Activation Metrics

| Metric | How to Measure | Good Benchmark |
|--------|---------------|---------------|
| Onboarding completion rate | Users completing onboarding / total signups | >60% |
| Time to first value | Minutes from signup to core action | <5 min ideal |
| Setup friction points | Drop-off at each onboarding step | Identify biggest drop |

### Retention Metrics

| Metric | How to Measure | Good Benchmark |
|--------|---------------|---------------|
| Day 1 retention | Users active day after signup / signups | >40% |
| Week 1 retention | Users active week 1 / signups | >25% |
| Month 1 retention | Users active month 1 / signups | >15% |
| Retention plateau | Where the curve flattens | Should flatten, not hit 0 |

### Revenue Metrics

| Metric | How to Measure | Good Benchmark |
|--------|---------------|---------------|
| Trial-to-paid conversion | Paid users / trial users | >5% (self-serve), >25% (sales) |
| ARPU | Total revenue / total active users | Depends on pricing |
| Expansion revenue | Upgrades + add-ons revenue | >20% of new MRR |
| Net revenue retention | See formula in main skill | >100% is great, >120% is excellent |

## Cohort Analysis Guide

### How to Read a Cohort Table

```
         Week 0  Week 1  Week 2  Week 3  Week 4
Jan W1    100%    45%     32%     28%     25%
Jan W2    100%    42%     30%     26%     --
Jan W3    100%    48%     35%     --      --
Jan W4    100%    44%     --      --      --
```

What to look for:
- **Vertical comparison**: Is Week 1 retention improving over time? (Jan W3 > Jan W1 = good)
- **Horizontal decay**: Where does retention stabilize? (If it hits 0, you have no PMF)
- **Step changes**: Did a product change improve retention for newer cohorts?

### Building Cohort Tables

```sql
-- PostHog HogQL or standard SQL
SELECT
  date_trunc('week', first_event) as cohort_week,
  date_trunc('week', event_time) as activity_week,
  count(distinct user_id) as users
FROM (
  SELECT
    user_id,
    min(timestamp) OVER (PARTITION BY user_id) as first_event,
    timestamp as event_time
  FROM events
  WHERE event = 'core_action'
) sub
GROUP BY 1, 2
ORDER BY 1, 2
```

## A/B Testing Methodology

### When to A/B Test
- You have enough traffic (>1000 visitors/week per variant)
- The change is measurable (conversion rate, not "feels better")
- You're willing to wait for statistical significance

### When NOT to A/B Test
- <100 conversions/week (not enough data)
- Obvious fixes (broken button, missing CTA)
- Early stage (<1000 users total) — just ship and iterate

### Test Process
1. **Hypothesis**: "Changing [X] will improve [metric] because [reason]"
2. **Minimum sample size**: Use a calculator (minimum 200 conversions per variant)
3. **Duration**: Run for at least 2 full weeks (captures weekly patterns)
4. **Significance**: p-value < 0.05 (95% confidence)
5. **Decision**: Significant + meaningful effect size → implement winner

### Common Mistakes
- Stopping the test early because one variant is "winning"
- Testing too many variants at once
- Not accounting for seasonality (run full weeks)
- Ignoring effect size (statistically significant but 0.1% improvement isn't worth it)


Security scan verdicts — ClawScan: clean | static analysis: clean | VirusTotal: clean | SkillSpector: clean (LOW)