No results for ""
EXPAND ALL
  • Home
  • API docs

Custom conversion binary metrics

Read time: 3 minutes
Last edited: Sep 30, 2024

Overview

This topic explains how to create a custom conversion binary metric in LaunchDarkly. Custom conversion binary metrics track whether an event occurs. 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:

  • Whether a customer submitted a form
  • Whether a payment succeeded
  • Whether an action produced an error
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 binary metric, you must first select Occurrence for what you want to measure.

Then, custom conversion binary metric definition options include:

  • Randomization 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 analysis.

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:

client.track("Example event key", context, value);

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.

Metric keys and event keys are different

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

Sending custom events to LaunchDarkly also requires an 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.

Try it in your SDK: Sending custom events

To create a custom conversion binary metric:

  1. Navigate to the Metrics list.
  2. Click Create metric. The "Create metric" dialog appears.
  3. Select an event kind of Custom.
  4. Enter an Event key.
  5. Choose Occurrence as what you want to measure.
A custom conversion binary metric.
A custom conversion binary metric.
  1. In the Metric definition section, select the following:
  • Percentage of [randomization 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.
  1. Enter a metric Name.
  2. (Optional) Add a Description.
  3. (Optional) Add any Tags.
  4. (Optional) Update the Maintainer.
  5. Click Create metric.

After you create a metric, you can connect it to an experiment or use it to monitor the performance of flag changes. To learn how, read Creating experiments and Release Guardian.

You can also use the REST API: Create metric