For AI agents: a documentation index is available at the root level at /llms.txt and /llms-full.txt. Append /llms.txt to any URL for a page-level index, or .md for the markdown version of any page.
Sign inTry it free
DocsGuidesSDKsIntegrationsAPI docsTutorialsFlagship blog
DocsGuidesSDKsIntegrationsAPI docsTutorialsFlagship blog
  • Get started
    • Overview
    • Onboarding
    • Get started
    • Launch Insights
    • LaunchDarkly architecture
    • LaunchDarkly vocabulary
  • AgentControl
    • AgentControl
    • Manage AgentControl
  • Feature flags
    • Create flags
    • Target with flags
    • Flag templates
    • Manage flags
    • Code references
    • Contexts
    • Segments
  • Releases
    • Releasing features with LaunchDarkly
    • Release policies
    • Percentage rollouts
    • Progressive rollouts
    • Guarded rollouts
    • Feature monitoring
    • Release pipelines
    • Engineering insights
    • Release management tools
    • Applications and app versions
    • Change history
    • Restoring previous flag versions
  • Observability
    • Observability
    • Session replay
    • Error monitoring
    • Logs
    • Traces
    • Observability metrics
    • Product analytics events
    • LLM observability
    • Alerts
    • Dashboards
    • Service map
    • Vega for auto-remediation
    • Observability MCP server
    • Search specification
    • Observability settings
    • Observability integrations
  • Experimentation
    • Experimentation
    • Experiment metric types
    • Experiment configuration
    • Managing experiments
    • Analyzing experiments
    • Multi-armed bandits
    • Holdouts
  • Metrics and events
    • Metrics in LaunchDarkly
    • Creating metrics
      • Components of a metric
      • Choosing a metric type
        • Page viewed conversion metrics
        • Clicked or tapped conversion metrics
        • Custom metrics
          • Custom conversion count metrics
          • Custom conversion binary metrics
          • Custom numeric metrics
          • Filtering custom metric events
      • Creating metrics from traces
      • Managing metrics
    • Metric groups
    • Events
    • Autogenerated metrics
  • Warehouse native
    • Warehouse native metrics
    • Setting up external warehouses
    • Creating experiments using warehouse native metrics
  • Infrastructure
    • Connect apps and services to LaunchDarkly
    • LaunchDarkly in China and Pakistan
    • LaunchDarkly in the European Union (EU)
    • LaunchDarkly in federal environments
    • Public IP list
  • Your account
    • Projects
    • Views
    • Environments
    • Tags
    • Teams
    • Members
    • Roles
    • Account security
    • Feature previews
    • Billing and usage
    • Changelog
Sign inTry it free
LogoLogo
On this page
  • Overview
  • Metric definition
  • Create custom conversion count metrics
Metrics and eventsCreating metricsChoosing a metric typeCustom metrics

Custom conversion count metrics

Was this page helpful?
Previous

Custom conversion binary metrics

Next
Built with

Overview

This topic explains how to create a custom conversion count metric in LaunchDarkly. Custom conversion count metrics track how many times an event occurs. You can use this metric with any event you set up in your codebase.

For example, you can use custom conversion count metrics to track:

  • How many times each user submitted a form
  • How many times each customer completed the checkout process
  • How many errors a new process produced
Call track and flush when an end user is redirected

SDKs send events at regular intervals, such as every five seconds. If a browser redirects an end user to another page, any events that occurred between when the SDK last sent events and when the browser redirected will be lost. To avoid this, call track and then flush when you know the browser will redirect an end user to another page, such as on click. To learn more, read Sending custom events and Flushing events.

Metric definition

When you create a custom conversion count metric, you must first select Count for what you want to measure.

Then, custom conversion count metric definition options include:

  • Analysis method:
    • Average: “average” is the default analysis method. This method calculates the average number of conversions per context. For metrics you plan to use in funnel metric groups, you must select “Average.”
    • Percentile: you can choose between P50-P99, which represent the 50th through the 99th percentile. This method counts the conversions per context, then finds the number of conversions that fall into the chosen percentile.
  • [analysis unit]: one or more context kinds, such as “user,” “device,” or “request,” that the metric can measure events from.
  • Success criteria:
    • Higher is better: choose this option for metrics measuring positive things like cart checkouts or sign-ups.
    • Lower is better: choose this option for metrics measuring negative things like errors.

To learn more about the metric definition options, read Metric components.

Create custom conversion count metrics

Custom conversion count metrics require an event key from your application’s code to track conversions for any event in your code. To add a custom conversion count metric in LaunchDarkly, you must identify it with a code snippet embedded in your app.

This is an example of tracking a custom event:

Example event
1client.track("example-event-key", context);

The area of your code you should put custom conversion count metric information into, and the type of information you should include, varies based on which SDKs you use. Often, the information you should put in your code includes the event key, context object, data field, or numeric value fields.

Event keys and metric keys are different

Sending custom events to LaunchDarkly requires a unique event key. You can set the event key to anything you want. Adding this event key to your codebase lets your SDK track actions customers take in your app as events. To learn more, read Sending custom events.

LaunchDarkly also automatically generates a metric key when you create a metric. You only use the metric key to identify the metric in API calls. To learn more, read Creating and managing metrics.

Try it in your SDK: Sending custom events

To create a custom conversion count metric:

  1. Open the Data section and navigate to the Metrics list.

  2. Click Create metric. The “Create metric” dialog appears.

  3. If you use warehouse native metrics, you can select either LaunchDarkly hosted or Warehouse native.

    • Select LaunchDarkly hosted to measure events from LaunchDarkly SDKs.
    • Select Warehouse native to measure events from an external warehouse, such as Snowflake.
      • Select an existing Metric data source or click + Create to create a new data source. To learn more, read Metric data sources.
  4. If you chose the LaunchDarkly hosted event source, select an event kind of Custom.

  5. Search for or enter an Event key.

    • A list of events your environment has recently received appears when you click into the Event key field. Begin typing an event key to view a list of events that match your search. Hover over an event from the list to view which environments the event appears in, which context kinds sent the latest event, and which SDKs the event is coming from.
  6. Choose Count as what you want to measure.

    A custom conversion count metric.

    A custom conversion count metric.
  7. In the Metric definition section, select the following:

    • analysis method for event count: select Average or a percentile between P50-P99.
    • per [analysis unit]: select the context kind for the metric to measure events from.
    • where higher is better or lower is better: select whether the desired outcome is a higher number or a lower number.
  8. Enter a metric Name.

  9. (Optional) Add a Description.

  10. (Optional) Add any Tags.

  11. (Optional) Update the Maintainer.

  12. Click Create metric.

You can connect the metric to an experiment or guarded rollout to monitor the impact of a flag change.

You can also use the REST API: Create metric