The AARRR Pirate Funnel
5 stacked torus rings represent the funnel stages. Press Run Funnel to cascade particles through. Press Drop Retention to watch the third ring shrink and users leak out.
Code example
Client-side event tracking for funnel analytics and a retention cohort SQL query.
// analytics.js — structured event tracking for AARRR
// Every event has a name, stage, and properties object
const analytics = {
track(event, stage, props = {}) {
// In prod: segment.track() / mixpanel.track() / amplitude.track()
console.log({ event, stage, props, timestamp: new Date().toISOString() });
}
};
// ACQUISITION — how users arrive
analytics.track('page_viewed', 'acquisition', {
source: document.referrer || 'direct',
utm_campaign: new URLSearchParams(location.search).get('utm_campaign'),
});
// ACTIVATION — first value moment
async function handleSignup(user) {
analytics.track('signup_completed', 'activation', { method: 'email' });
await createProject(user); // force the first value moment
analytics.track('first_project_created', 'activation');
}
// RETENTION — returning users
const lastVisit = localStorage.getItem('last_visit');
const daysSince = lastVisit
? (Date.now() - new Date(lastVisit)) / 86400000
: null;
if (daysSince !== null) {
analytics.track('session_started', 'retention', { days_since_last: daysSince });
}
localStorage.setItem('last_visit', new Date().toISOString());
// REVENUE — paid conversion
analytics.track('subscription_started', 'revenue', {
plan: 'pro', mrr: 29, trial_days: 14
});
// REFERRAL — sharing behaviour
analytics.track('invite_sent', 'referral', { channel: 'email', count: 3 });
-- Retention cohort analysis (PostgreSQL)
-- Shows % of users from each signup week who returned in weeks 1—8
WITH cohorts AS (
SELECT
user_id,
DATE_TRUNC('week', created_at) AS cohort_week
FROM users
WHERE created_at >= '2026-01-01'
),
activity AS (
SELECT
user_id,
DATE_TRUNC('week', event_at) AS activity_week
FROM events
WHERE event_name = 'session_started'
)
SELECT
c.cohort_week,
COUNT(DISTINCT c.user_id) AS cohort_size,
COUNT(DISTINCT CASE WHEN week_number = 1 THEN a.user_id END) * 100.0
/ COUNT(DISTINCT c.user_id) AS week_1_retention,
COUNT(DISTINCT CASE WHEN week_number = 4 THEN a.user_id END) * 100.0
/ COUNT(DISTINCT c.user_id) AS week_4_retention,
COUNT(DISTINCT CASE WHEN week_number = 8 THEN a.user_id END) * 100.0
/ COUNT(DISTINCT c.user_id) AS week_8_retention
FROM cohorts c
JOIN activity a ON c.user_id = a.user_id
CROSS JOIN LATERAL (
SELECT EXTRACT('week' FROM a.activity_week - c.cohort_week) AS week_number
) w
GROUP BY c.cohort_week
ORDER BY c.cohort_week;
-- Healthy SaaS benchmark: week-4 retention > 25%
-- "Smiling" retention curve = product has found product-market fit
Key concepts
AARRR Funnel
Dave McClure's "Pirate Metrics" framework. Every user moves through 5 stages. Most products leak badly at Activation (users sign up but never get value) and Retention (users get value once but don't return).
Retention
The single most important metric. If retention is broken, acquisition spend is wasted — you're pouring water into a leaky bucket. A "smiling" retention curve (flattens above 0%) means you've found product-market fit.
NPS
Net Promoter Score: "How likely are you to recommend us?" Promoters (9—10) minus Detractors (0—6) = NPS. Ranges from -100 to +100. Above 50 is excellent. Below 0 means detractors outnumber promoters.
DAU/MAU
Daily Active Users — Monthly Active Users = stickiness. 20% DAU/MAU means users return on average 6 days per month. WhatsApp hits ~70%. A low ratio means users don't find daily value in your product.