Read time: 2 minutes
Last edited: May 12, 2023
This topic explains how to create a metric to use within an experiment in LaunchDarkly.
Metrics measure audience behaviors affected by the flags in your experiments. You can use metrics to track all kinds of things, from how often customers access a URL to how long that URL takes to load a page. Create metrics that align with your business goals and connect them to your team's flags to track the impact of different flag variations over time.
Understanding types of metrics
Conversion metrics register events when an end user takes an action based on a feature flag they encounter. Conversion metrics can track
page view, and
custom event kinds. Numeric metrics measure numeric values against a baseline you set. Numeric metrics can track the
custom event kind. To learn more about event kinds, read Analytics events.
There are four metric options in LaunchDarkly:
The following table explains the kinds of events you can track with a metric and their SDK compatibility:
|Event kind||Metric||Description||SDK compatibility|
|Custom||Conversion||Tracks events for any arbitrary event.||All|
|Custom||Numeric||Tracks increases or decreases in numeric value against a baseline you set.||All|
To learn more about Experimentation events, read Experimentation events.
Choosing a metric
You should choose a metric type that correctly measures the effect of a change on your customers or codebase. If you are unsure of what metric type to use, it may be helpful to begin by determining what kind of data you are trying to measure.
When you create a metric, you will map the new metric to a context kind you have marked as available for experiments:
To learn more, read Randomization units.
This table includes examples of different kinds of data you can measure with different metric types, and common randomization unit context kind mappings:
|Metric type||Example uses||Example randomization unit context kind mappings|
|Click conversion||How often do customers click a "Save" button?|
How many times do customers click on a link?
When is the best point during a process to display a sign-up invitation?
|Custom conversion||Do customer searches call a particular service?|
Do customers contact customer service within a set period of time?
Do customers renew their contract within 30 days?
Do customer payments succeed?
|Custom numeric||How much do customers spend per transaction in my store?|
How much do customers spend in total?
How many items do customers purchase per transaction?
How many items do customers purchase total?
How much time do customers spend on a page?
How long does it take for a server to respond to a request?
How long until the time to first byte (TTFB)?
|Page view conversion||How many times do end users view a blog post?|
Connecting a metric to an experiment
After you create a metric, you can use it in one or more experiments. The randomization unit you map the metric to must match the context kind you want to randomize on.
In this example, the experiment has a randomization unit of
customer. It is compatible with the chosen metric, because the metric can measure events from
customer context kinds.
To learn more, read Building experiments.
You should delete a metric only when you are sure you will no longer use it in any experiments.
To delete a metric:
- Navigate to the Experiments list.
- Click the Metrics tab.
- Click the title of the metric you want to delete. The "Edit metric" panel appears.
- Click Delete this metric.
This metric is now deleted permanently across all environments in the project.