This topic explains how to create a custom numeric metric in LaunchDarkly. Custom numeric metrics track changes to the amount of something, such as dollars spent or latency time. Unlike conversion metrics, which track how many users triggered an event or the number of times an event occurs, numeric metrics let you measure changes in value against a baseline flag variation you choose.
For example, you can use numeric metrics to track:
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.
When you create a custom numeric metric, you must first decide:
Then, custom numeric metric definition options include:
To learn more about the metric definition options, read Metric components.
You cannot use custom numeric metrics in funnel metric groups. To learn more, read Funnel metric groups.
To add a custom numeric metric in LaunchDarkly, you must identify it with a code snippet embedded in your app.
This is an example of sending a custom event:
Numeric metrics require an event key from your application’s code to track metric data. The area of your code you should put custom metric information into, and the type of information you should include, vary based on which SDKs you use.
Usually, the information you should put in your code includes the event key, context object, data field, or numeric value fields.
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 numeric metric:
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.
If you chose the LaunchDarkly hosted event source, select an event kind of Custom.
Search for or enter an Event key.
Choose Value/size as what you want to measure.

Choose how multiple event values are aggregated per unit:
In the Metric definition section, select the following:
Select an option to handle units without events:
0: Select this option for metrics where an incomplete process can be treated the same as 0, such as for tracking cart totals for an online store.Enter a Unit of measure.
Enter a Metric Name.
(Optional) Add a Description.
(Optional) Add any Tags.
(Optional) Update the Maintainer.
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