About custom conversion count metrics
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
Example metric in SQL
Some customers find it helpful to think about LaunchDarkly metric calculations in terms of SQL statements. The following example shows how a custom conversion count metric could be represented as a SQL expression, using example table and column names to represent metric components:eventsis a table that stores all of the metric events on which the metric is defined.user_idis a table column that represents the context both for the metric analysis unit and for the randomization unit used in the experiment or guarded rollout. This example uses the “user” context kind, but a metric can use other context kinds, such as “account,” “session,” or “device.”aggregation_funcrepresents the aggregation function that corresponds to the analysis method you select, such asAVGfor average analysis orPERCENTILE_CONTfor percentile analysis.
Metric definition
When you configure the metric definition for a custom conversion count metric, you first select Count as the aggregation type for your measurement, and then select one or more context kinds for which you will count events. You then choose from options to define the analysis method and success criteria:- 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.”
- P50 to P99: to use percentile analysis, choose between P50-P99. The options 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.
- 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.
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 acustom event:
Try it in your SDK: Tracking custom events
- Open the Data section and navigate to the Metrics list.
- Click Create metric. The “Create metric” dialog appears.
-
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.
- If you chose the LaunchDarkly hosted event source, select an event kind of Custom.
-
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.
-
In the Metric definition section, choose Count from the drop-down menu. The window populates a full metric definition using default values.

A custom conversion count metric.
-
Change options in the “Metric definition” drop-down menus as needed:
- Change or select additional context kinds to use as the analysis units for the metric. Only context kinds marked as available for experiments and guarded rollouts appear as options. To learn more, read Mark context kinds available for experiments.
- Select Average or a percentile between P50 to P99 to configure the analysis method.
- Choose higher is better or lower is better to define success criteria for attached experiments or guarded rollouts.
- Enter a metric Name.
- (Optional) Add a Description.
- (Optional) Add any Tags.
- (Optional) Update the Maintainer.
- Click Create.
You can also use the REST API: Create metric