Skip to content

Defining Metrics

GrowthBook uses a two-layer model:

  1. Fact Table — a thin wrapper around a raw event table in your warehouse. It defines which SQL query surfaces the raw events and which columns represent the user ID, timestamp, and numeric value.
  2. Metric — a statistical definition built on top of a Fact Table. It says how to aggregate the raw events into a number per user per experiment.

This separation means you define your data shape once (Fact Table) and can compose many different metrics from it without duplicating SQL.

TypeDefinitionExample
ProportionPercentage of users who did the event at least onceConversion rate, click-through rate
MeanAverage numeric value per userAverage order value, average session duration
RatioNumerator metric divided by denominator metricRevenue per session, pages per visit
  1. In the left sidebar, go to Analysis then Fact Tables.
  2. Click Add Fact Table.
  3. Give it a name (e.g. Orders).
  4. Select your Data Source.
  5. Write the SQL query that surfaces the raw events. The query must return at minimum:
    • A user identifier column
    • A timestamp column
    • (For mean/ratio metrics) a numeric value column

Example Fact Table SQL for an orders table:

SELECT
user_id,
timestamp,
revenue_usd
FROM
`myproject.analytics.orders`
WHERE
timestamp >= '{{ startDate }}'
AND timestamp <= '{{ endDate }}'
  1. Map the User ID column and Timestamp column in the Fact Table settings.
  2. Click Save.
  1. In the left sidebar, go to Analysis then Metrics.
  2. Click Add Metric.
  3. Choose the metric type: Proportion, Mean, or Ratio.
  4. Select the Fact Table you just created.
  5. For a Mean metric, choose the numeric value column (e.g. revenue_usd).
  6. Set the Metric Window — the time window after assignment in which to count events (e.g. 14 days). This prevents long-tail events from polluting the analysis.
  7. Optionally set:
    • Minimum sample size — GrowthBook will not show results until this threshold is reached.
    • Maximum percentage change — alerts you if uplift looks suspiciously large.
  8. Click Save Metric.

For cases where a Fact Table is not the right abstraction, GrowthBook also supports defining a metric with raw SQL directly. Here is a proportion metric that counts users who placed at least one order:

-- Proportion metric: "Purchased"
-- Returns one row per user who placed an order.
-- GrowthBook computes the conversion rate: ordered_users / assigned_users.
SELECT
  user_id,
  timestamp
FROM
  `myproject.analytics.orders`
WHERE
  timestamp >= '{{ startDate }}'
  AND timestamp <= '{{ endDate }}'
What is the purpose of a Fact Table in GrowthBook?
Which metric type calculates the percentage of users who triggered an event at least once?
What does the Metric Window setting control?
Why is separating Fact Tables from Metrics useful?