Custom conversion metrics
Read time: 1 minute
Last edited: Mar 01, 2023
Overview
This topic explains how to create a custom conversion metric for an experiment in LaunchDarkly.
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 browser redirected the end user 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.
Creating custom conversion metrics
Custom conversion metrics require you to create an event name and insert it into your application to track conversions for any event in your code. To add a custom conversion metric in LaunchDarkly, you must identify it with a code snippet embedded in your app.
To add a custom
event:
client.track("Example event name", context, value);
The area of your code you should put custom conversion 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. To learn more, read the Sending custom events documentation for your SDKs.
To create a custom conversion metric:
- Follow steps 1-7 in Creating click conversion metrics until you have configured the form up to the "Event information" section.
- Click the Event kind menu and select "Custom":

- Select the Conversion radio button.
- Enter a human-readable Event name. This is the event name you will reference in your code snippet when you insert the metric information into your app.
- Choose one or more context kinds available for experiments for the metric to measure events from.
Using invalid randomization units will result in invalid experiment results. To learn more, read Randomization units. If you're unsure of which randomization unit to use, contact Support for help determining valid context kind selections.
- Click Save metric:

After you create a metric, you can connect it to an experiment. To learn how, read Building experiments.
You can also use the REST API: Create metric