> ## Documentation Index
> Fetch the complete documentation index at: https://launchdarkly-preview.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Custom conversion binary metrics

> This topic explains how to create a custom conversion binary metric in LaunchDarkly.

> For the complete documentation index, see [llms.txt](/llms.txt). For the full documentation snapshot, see [llms-full.txt](/llms-full.txt).

## Overview

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

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

* How many customers submitted a form
* How many customers made a successful payment
* How many customers encountered an error

<Warning title="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](/sdk/features/events) and [Flushing events](/sdk/features/flush).
</Warning>

## Metric definition

When you create a custom conversion binary metric, you must first select **Occurrence** for what you want to measure.

Then, custom conversion binary metric definition options include:

* Percentage of **\[analysis unit]** units that sent the event: 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](/home/metrics/components).

## Create custom conversion binary metrics

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

This is an example of sending a `custom` event:

<CodeGroup>
  ```java title="Example event" theme={null}
      client.track("Example event key", context);
  ```
</CodeGroup>

The area of your code you should put custom conversion binary 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.

<Warning title="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](/sdk/features/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](/home/metrics/create-metrics).
</Warning>

<Card
  icon={<img src="https://fern-image-hosting.s3.us-east-1.amazonaws.com/launchdarkly/terminal.svg" class="terminal" />

}
  iconPosition="left"
>
  Try it in your SDK: [Sending custom events](/sdk/features/events)
</Card>

To create a custom conversion binary metric:

1. Navigate to the **Metrics** list.
2. Click **Create metric**. The "Create metric" dialog appears.
3. If you use [Snowflake native Experimentation](/home/warehouse-native/snowflake), you have the option to 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](/home/warehouse-native/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 on 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 **Occurrence** as what you want to measure.

<Frame caption="A custom conversion binary metric.">
  ![A custom conversion binary metric.](https://files.buildwithfern.com/https://launchdarkly.docs.buildwithfern.com/docs/f22d7ff2d2834bbf67d7e02566fe2bfc728d6f9c7e8e8a3e7d8b8880c4d5a1fe/assets/images/auto/metrics-event-kind-custom-conversion.auto.png)
</Frame>

7. In the [Metric definition](#metric-definition) section, select the following:
   * Percentage of **\[analysis unit]** units that sent the event: 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](/home/experimentation/create) or [guarded rollout](/home/releases/guarded-rollouts) to monitor the impact of a flag change.

<Card icon="link">
  You can also use the REST API: [Create metric](/api-reference/metrics/create-metric)
</Card>
