Telemetry
Revenue and billing SQL recipe

Calculate Trial-to-Paid Conversion

Measure how many trial accounts become paid customers within a fixed conversion window.

Intermediatesubscription_eventsReviewed 2026-07-27Tested with Apache DataFusion 45.2.0

Question answered

Which trial cohorts and acquisition sources convert to paid accounts?

A conversion rate needs a cohort, a deadline, and one counting unit. This query anchors accounts on their first trial and counts only paid events within 30 days.

Event contract

Fields the query expects

FieldTypeWhy it exists
timestamp_utcTimestampSubscription event time.
account_idUtf8Stable billing account identifier.
event_nameUtf8trial_started or subscription_started.
acquisition_sourceUtf8Source captured when the trial began.
DataFusion SQL

Copy the query

sql
WITH trials AS (
  SELECT
    account_id,
    MIN(timestamp_utc) AS trial_started_at,
    MIN(acquisition_source) AS acquisition_source
  FROM subscription_events
  WHERE event_name = 'trial_started'
    AND timestamp_utc >= now() - INTERVAL '120 days'
  GROUP BY account_id
),
paid AS (
  SELECT
    account_id,
    MIN(timestamp_utc) AS paid_at
  FROM subscription_events
  WHERE event_name = 'subscription_started'
  GROUP BY account_id
)
SELECT
  date_trunc('week', trials.trial_started_at) AS trial_week,
  trials.acquisition_source,
  COUNT(*) AS trial_accounts,
  SUM(CASE
    WHEN paid.paid_at >= trials.trial_started_at
      AND paid.paid_at < trials.trial_started_at + INTERVAL '30 days'
    THEN 1 ELSE 0
  END) AS paid_accounts,
  100.0 * SUM(CASE
    WHEN paid.paid_at >= trials.trial_started_at
      AND paid.paid_at < trials.trial_started_at + INTERVAL '30 days'
    THEN 1 ELSE 0
  END) / NULLIF(COUNT(*), 0) AS conversion_rate_pct
FROM trials
LEFT JOIN paid ON paid.account_id = trials.account_id
GROUP BY
  date_trunc('week', trials.trial_started_at),
  trials.acquisition_source
ORDER BY trial_week, acquisition_source;

This read-only query is planned and executed against an empty typed table with Apache DataFusion 45.2.0. The deterministic sample output is synthetic and reviewed separately; validate field types, thresholds, and business definitions against your own data. Read the testing methodology.

Query result

Thirty-day trial conversion by source

Product referrals convert at the highest rate despite having the smallest cohort.

trial_weekacquisition_sourcetrial_accountspaid_accountsconversion_rate_pct
2026-06-29docs1844122.28
2026-06-29paid_search3103711.94
2026-07-06product_referral962829.17

Synthetic example output. Run the query against your own event schema and thresholds before using it for operational decisions.

How the SQL works

  1. 1The trial CTE creates one cohort record per account.
  2. 2The paid CTE prevents multiple subscription events from counting the same account twice.
  3. 3The 30-day condition keeps cohorts comparable even when eventual conversion happens much later.

Edge cases to decide

  • Exclude cohorts that have not had the full conversion window before comparing final rates.
  • Decide how a cancelled and restarted trial should enter the cohort.
  • Persist acquisition source at trial start so later attribution changes do not rewrite history.

Recommended dashboard

  • Bars: conversion_rate_pct by acquisition_source
  • Trend: paid conversion by trial_week
  • Table: trials approaching the end of the conversion window

Alert guidance

Use a weekly review alert when a mature cohort falls materially below its trailing source baseline.

Read alert setup

Put the recipe to work

Related instrumentation and guides

Continue the analysis

Run it on real events

Create a table, adapt the fields, and save the result

Start free, send structured events, and use the query result as a chart, shared dashboard widget, or alert input.

Get an API key