Telemetry
Browse docs
Discussion TopicsUpdated July 28, 2026Reviewed by the Telemetry product team2 min read

Use this doc with your coding agent

Copy a Telemetry prompt and ask Claude Code, Codex, or Cursor to instrument the workflow covered here.

SQL Funnel Analysis

A funnel measures how a defined population progresses through milestones. The SQL is straightforward only after the product definition is precise: who enters, whether steps must occur in order, how long users have to progress, which identity represents a person or account, and how retries and duplicate events behave.

Reduce events to one row per actor

WITH account_steps AS (
  SELECT
    account_id,
    MIN(CASE WHEN event_name = 'signup_completed' THEN timestamp_utc END)
      AS signed_up_at,
    MIN(CASE WHEN event_name = 'workspace_created' THEN timestamp_utc END)
      AS workspace_created_at,
    MIN(CASE WHEN event_name = 'first_event_sent' THEN timestamp_utc END)
      AS first_event_sent_at
  FROM product_events
  WHERE timestamp_utc >= now() - INTERVAL '30 days'
  GROUP BY account_id
)
SELECT
  COUNT(*) AS accounts_seen,
  SUM(CASE WHEN signed_up_at IS NOT NULL THEN 1 ELSE 0 END) AS signed_up,
  SUM(CASE
    WHEN workspace_created_at >= signed_up_at THEN 1 ELSE 0
  END) AS created_workspace,
  SUM(CASE
    WHEN first_event_sent_at >= workspace_created_at THEN 1 ELSE 0
  END) AS sent_first_event
FROM account_steps
WHERE signed_up_at IS NOT NULL;

This conditional approach makes the milestone definition reviewable. It also prevents a many-to-many self-join from multiplying an actor's events. Add a maximum conversion window when the question requires progression within a fixed period.

Keep cohort and observation windows distinct

If the query includes signups from yesterday, those accounts have had less time to activate than accounts from the start of the month. Either allow every cohort a complete observation window or label recent cohorts as incomplete. Filtering all events to the same calendar range can unintentionally cut off valid later milestones.

Choose an account identifier for account-level activation and a user identifier for person-level behavior. Do not switch identities between steps. Define how merged accounts, anonymous sessions, reopened accounts, and repeated completions work.

Always show step counts beside percentages. A conversion change can come from the numerator, denominator, traffic mix, or instrumentation. The tested signup funnel recipe and conversion-rate guide provide a complete starting point. Use Cohort Retention when the question is continued behavior after activation.