Skip to main content
The tutorial consists of the following steps:
  1. Create an entity that represents the users that are part of your experiments.
  2. Create an assignment table that tells Confidence how your entity is assigned to experiments.
  3. Create a fact table that makes some measurable facts available for metrics.
  4. Create a metric that aggregates a measurement from the fact table.
If you already have an entity and an assignment table you can skip directly to create a fact table.
This page targets the following audiences:
  • Data Engineers or Data Scientists who want to set up Confidence Metrics for their organization.
Before you begin:
  • You need to have a Confidence account.
  • (Step 2-3) You need to have connected Confidence Metrics to your data warehouse.
  • (Step 2-3) You need to have data for metrics in your data warehouse.
Use this guide to set up a metric from scratch. Use the metric in the rollout quickstart to measure the effect of the change you roll out.

Create an Entity

An entity is a representation of the users that are part of your experiments. Entities can be anything really, but typically they are users, customers, or visitors. In Confidence, the entity connects other concepts such as experiments, variants, facts, dimensions and metrics to each other. It’s via the entity Confidence can understand how it should traverse the data in your data warehouse. For example, when you configure an experiment to use the User entity, Confidence only considers metrics that use facts that have a relationship to the User entity. Confidence comes with two default entities: User and Visitor. If you want to experiment on and create metrics for another entity, follow these steps.
1

Go to Confidence

2

Navigate to Entities

On the left sidebar, select Admin > Entities.
3

Click + Create

4

Enter User as the name of the entity

5

Select a data type

Select a data type for how your data warehouse represents the entity. For the sake of this tutorial, select String.
6

Click Create

🎉 That’s it! You have now created an entity that you can tie other concepts to in Confidence. In the next section, you use the entity when creating an assignment table so that Confidence knows how your new entity is assigned to experiments and variants.

Create an Assignment Table

If you have already set up an assignment table, you can skip this section. Jump straight to Create a metric.
The most fundamental part of Confidence Metrics is the experiment assignment data. Without it you can’t compute metrics for an A/B test or any type of experiment. Assignment data is a log of records that contain information about the how users were assigned to experiments and variants. Confidence needs the following data:
  • A timestamp that indicates when the assignment happened.
  • An entity identifier, normally a user identifier, that uniquely identifies the user that was assigned a variant.
  • An experiment identifier that identifies the experiment that the user was assigned to.
  • A variant identifier that identifies the variant that the user was assigned to.
Any table in your data warehouse can store the assignment data. For Confidence to understand the data, you need to tell Confidence where to find it and how to interpret it. You define this in your Assignment Table, which is a query that projects the data outlined above. You can write the query in any SQL dialect that your data warehouse supports. For this tutorial, your assignment data should exist in a table called assignment_log in your data warehouse. Data should be continuously appended to the table as users are assigned to experiments. The table has the following schema:
CREATE TABLE assignment_log (
  timestamp TIMESTAMP,
  user_id STRING,
  experiment_id STRING,
  variant_id STRING
)
Follow these steps to setup an assignment table:
1

Go to Confidence

2

Navigate to Assignment tables

On the left sidebar, select Admin > Assignment tables.
3

Click + Create

4

Give the table a name

Give the table a name, such as assignment. If your data comes from a particular feature flagging system, you can name it after that, for example launchdarkly.
5

Enter the SQL query

Enter the SQL query that projects the assignment data from your data warehouse.
SELECT
  timestamp,
  user_id,
  experiment_id,
  variant_id
FROM assignment_log
6

Click Run Query

This executes the query and shows you a preview.
To make the query cheap, the query runs with a LIMIT clause to limit the number of rows.
7

Map the columns

To the right of the result table, you see a form where you can specify the columns in the result that correspond to the assignment data. It’s this mapping that tells Confidence how to interpret the data. Fill in the form as follows:
  • timestamp as the timestamp column.
  • For entity, select User and enter user_id as the entity column.
  • experiment_id as the experiment key column.
  • variant_id as the variant key column.
8

Configure data delivery cadence

For Data delivery cadence select Data is delivered continuously. Leave Commit delay at its default value. You can read more about these settings on the data delivery cadence page.
9

Click Create

You have now set up an assignment table and can move on to create fact tables and metrics for your experiments.

Create a Fact Table

Facts are measurable data that you want to use in your metrics. Facts can be anything that you can measure, such as revenue, number of clicks, or number of impressions. Facts are stored in tables in your data warehouse. For Confidence to understand the data, you need to tell Confidence where to find it and how to interpret it. This tutorial assumes you have your fact data in a table called sales in your data warehouse. Each time a sale occurs, the system adds a new row to the data. amount is the sales amount and product is the product sold. Assume that data is continuously appended to the table as sales happen. The table has the following schema:
CREATE TABLE sales (
  timestamp TIMESTAMP,
  user_id STRING,
  amount FLOAT,
  product STRING
)
Follow these steps to setup a fact table:
1

Go to Confidence

2

Navigate to Fact tables

On the left sidebar, select Admin > Fact tables.
3

Click + Create

4

Give the table a name

Give the table a name, such as sales.
5

Enter the SQL query

Enter the SQL query that projects the fact data from your data warehouse.
SELECT
  timestamp,
  user_id,
  amount,
  product
FROM sales
6

Click Run Query

This executes the query and shows you a preview.
7

Map the columns

To the right of the result table, you see a form where you can specify the columns in the result that correspond to the fact data. It’s this mapping that tells Confidence how to interpret the data. Fill in the form as follows:
  • Select timestamp as the timestamp column.
  • For entity, select User and select user_id as the entity column.
  • Add amount to the list of measurements.
  • Add product to the list of dimensions.
8

Configure data delivery cadence

For Data delivery cadence select Data is delivered continuously. Leave Commit delay at its default value. You can read more about these settings on the data delivery cadence page.
9

Click Create

Create a Metric

The final step is to create a metric that aggregates the fact data. A metric can be any aggregation of the fact data, such as sum, average, count, etc. All metrics aggregate measurements over some time window. Watch this video for an overview of the different ways to handle time in metrics in 4 minutes and 34 seconds.
For this tutorial, create a metric that computes the average minutes of podcasts streamed per user for a week. To create a metric follow these steps:
1

Go to Confidence

2

Navigate to Metrics

On the left sidebar, select Metrics.
3

Click + Create

4

Enter metric details

Enter Average weekly sales per user as the name of the metric and assign yourself as the owner. Skip the description for now.
5

Select Consumption as the metric type

6

Select the consumption value

Select the User entity, the sales fact table, and the amount measurement as the Consumption value.
7

Add attribute criteria

Click Add Attribute criteria and select content_type as the attribute. Set the filter to content_type is podcast.
8

Configure when to include users

In the When to Include Users In Metrics Results step, select Cumulatively during a window and 1 week starting at exposure.
9

Click Next to skip the Suggested usage

10

Review and create

Review your metric setup, and then click Create.
That’s it! You have now created your first metric. You can now create an A/B test using the metric. Well done.