• Home
  • Integrations
  • SDKs
  • Guides
  • API docs
    No results for ""


    Creating metrics

    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.

    You can also use the REST API: Metrics

    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 click, 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:

    • Click conversion metrics
    • Custom conversion metrics
    • Custom numeric metrics
    • Page view conversion metrics

    The following table explains the kinds of events you can track with a metric and their SDK compatibility:

    Event kindMetricDescriptionSDK compatibility
    ClickConversionTracks the clicks on a user interface (UI) element.JavaScript
    CustomConversionTracks events for any arbitrary event.All
    CustomNumericTracks increases or decreases in numeric value against a baseline you set.All
    Page viewConversionTracks how many times a page is viewed.JavaScript

    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:

    The "Randomization unit" mapping field in a metric creation panel.
    The "Randomization unit" mapping field in a metric creation panel.

    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 typeExample usesExample randomization unit context kind mappings
    Click conversionHow 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 conversionDo 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 numericHow 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 conversionHow many times do end users view a blog post?user

    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.

    The experiment creation screen with randomization units for the experiment and the metric called out.
    The experiment creation screen with randomization units for the experiment and the metric called out.

    To learn more, read Building experiments.

    Deleting metrics

    You should delete a metric only when you are sure you will no longer use it in any experiments.

    To delete a metric:

    1. Navigate to the Experiments list.
    2. Click the Metrics tab.
    3. Click the title of the metric you want to delete. The "Edit metric" panel appears.
    4. Click Delete this metric.

    This metric is now deleted permanently across all environments in the project.

    You can also use the REST API: Delete metric