Read time: 4 minutes
Last edited: Sep 15, 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.
To view your list of metrics, navigate to the Metrics list:
There are two main types of metrics in LaunchDarkly:
- Conversion/binary metrics register events when an end user takes an action based on a feature flag they encounter.
- Numeric metrics measure numeric values against a baseline you set. Numeric metrics can track the
customevent kind. To learn more about event kinds, read Analytics events.
The following table explains the kinds of events you can track with a metric and their SDK compatibility:
|Event kind||Metric||Description||SDK compatibility|
Tracks the clicks on a user interface (UI) element.
Tracks events for any arbitrary event.
Tracks increases or decreases in numeric value against a baseline you set.
Tracks how many times a page is viewed.
You can send
custom events using the track feature in your SDK. To learn more about Experimentation events, read Experimentation events.
Click on the following links below to learn how to create each metric option:
- Click conversion metrics
- Custom conversion/binary metrics
- Custom numeric metrics
- Page view conversion metrics
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|
How often do customers click a "Save" button?
Do customer searches call a particular service?
How much do customers spend per transaction in my store?
|Page view conversion|
How many times do end users view a blog post?
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
user. It is compatible with the chosen metric, because the metric can measure events from
user 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 Metrics list.
- Click the title of the metric you want to delete. The metric details screen opens.
- Click Delete.
This metric is now deleted permanently across all environments in the project.