This topic explains how to create a clicked or tapped metric for use in LaunchDarkly experiments, guarded rollouts, or release policies.
Clicked or tapped metrics track how often an end user interacts with an element of your product’s UI. For example, you can use clicked or tapped metrics to track:
LaunchDarkly’s observability features include a session replay plug-in that automatically tracks user clicks during a session recording. You can use the session replay click properties (clickSelector, clickContextContent, and clickTarget) to filter the sessions displayed in the Sessions tab of the LaunchDarkly UI. However, you cannot use those properties as events for creating new metrics.
This topic describes how to instrument click or tapped events and metrics that you can use to create experiments or guarded rollouts.
Clicked or tapped metrics are only compatible with the following JavaScript-based client SDKs:
If you do not use one of these SDKs and would like to track clicks or taps, use a custom conversion binary metric instead.
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, flush events when you know the browser will redirect an end user to another page, such as on click. To learn more, read Flushing events.
CSS selectors designate specific areas of your product UI, like buttons or images, that your end users can interact with. You can create a metric that monitors interaction with one or more CSS selectors.
For example, some CSS selectors include:
#example-element-id.example-classnamebutton.example-button.example-button, .example-button-altThe CSS selector must be present in your application after the end user interacts with it in order for LaunchDarkly to record the metric. For example, if the end user clicks an element that is dynamically removed from your application in response to the click, then LaunchDarkly will not record the metric event.
If the CSS selector will not be present after the end user interacts with it, we recommend using a custom conversion binary metric instead. To learn more, read Custom conversion binary metrics.
When you create a clicked or tapped conversion metric, you must first decide:
Then, clicked or tapped conversion metric definition options include:
To learn more about the metric definition options, read Metric components.
To create a clicked or tapped metric:
In the Metric definition section, select the following:

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 filter the metric events to specific context attributes or event properties.
You can also use the REST API: Create metric