> ## 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.

# Clicked or tapped conversion metrics

> This topic explains how to create a clicked or tapped metric for use in LaunchDarkly experiments, guarded rollouts, or release policies.

> 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 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:

* How often a customer clicks a "Save" button when it is red, versus how often a customer clicks the "Save" button when it is blue
* How often a customer clicks the same "Save" button across different URLs by tracking URLs based on substrings or simple matches

<Warning title="Click or tapped events are different from session replay click properties">
  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.
</Warning>

## Prerequisites

Clicked or tapped metrics are only compatible with the following JavaScript-based client SDKs:

* Electron
* JavaScript
* Node.js (client-side)
* React Web
* Vue

If you do not use one of these SDKs and would like to track clicks or taps, use a [custom conversion binary metric](/home/metrics/custom) instead.

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

## CSS selectors

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-classname`
* `button.example-button`
* `.example-button, .example-button-alt`

The 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](/home/metrics/custom).

## Metric definition

When you create a clicked or tapped conversion metric, you must first decide:

* What do you want to measure:
  * **Count**: the number of times a target was clicked.
  * **Occurrence**: whether or not a target was clicked.

Then, clicked or tapped conversion metric definition options include:

* Analysis method:
  * for metrics measuring count, you can analyze by:
    * **Average**: "average" is the default analysis method. This method calculates the average number of clicks or taps per context. For metrics you plan to use in funnel metric groups, you must select "Average."
    * **Percentile**: you can choose between P50-P99, which represent the 50th through the 99th percentile. This method counts the clicks or taps per context, then finds the number of clicks or taps that fall into the chosen percentile.
  * for metrics measuring occurrence, the metric automatically sets the analysis method to "average."
* **\[analysis unit]**: one or more context kinds, such as "user," "device," or "request," that the metric can measure events from.

To learn more about the metric definition options, read [Metric components](/home/metrics/components).

## Create clicked or tapped metrics

To create a clicked or tapped 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**.
4. Select an event kind of **Clicked or tapped**.
5. Enter one or more CSS selectors in the **Click targets** field. If you include multiple CSS selectors, separate them with commas.
6. Specify the **Target type** you want to track behavior on. Expand the section below to view the four types of URL matching.

<Accordion title="Expand URL matching options">
  \| URL matching schema

  \| Description

  | Example |
  | - |

  \| ---

  \| --- |
  \| Simple match

  \| This sends an event when the end user accesses a URL, or clicks on an element hosted at a URL, that matches the string you enter in the Target URL field or a formulation of that URL that included appended parameters. If you want events to record for URLs with substrings, specify each URL individually.

  \| If you specify:

  <ul><li> <code>[https://www.example.com](https://www.example.com)</code> </li></ul> Then LaunchDarkly sends events from views or clicks at:

  <ul><li> <code>[https://www.example.com](https://www.example.com)</code> </li> <li> <code>[https://www.example.com#signin](https://www.example.com#signin)</code> </li></ul> If you specify:

  <ul><li> <code>[https://www.example.com](https://www.example.com)</code> , and </li> <li> <code>[https://www.example.com/login](https://www.example.com/login)</code> </li></ul> Then LaunchDarkly sends events from views or clicks at:

  <ul><li> <code>[https://www.example.com](https://www.example.com)</code> </li> <li> <code>[https://www.example.com/login](https://www.example.com/login)</code> </li></ul> |
  \| Exact match

  \| This sends an event when the end user accesses a URL, or clicks on an element hosted at a URL, that exactly matches what you enter in the Target URL field. Identical base URLs with different substrings do not send events.

  \| If you specify:

  <ul><li> <code>[https://www.example.com](https://www.example.com)</code> </li></ul> Then LaunchDarkly sends events from views or clicks at:

  <ul><li> <code>[https://www.example.com](https://www.example.com)</code> </li></ul> Views and clicks at <code>[https://www.example.com/login](https://www.example.com/login)</code> and <code>[https://www.example.com#signin](https://www.example.com#signin)</code> do not send events. |
  \| Regular expression

  \| This sends an event based on a regex expression you specify. This lets you designate more precise locations to send click and page view events.

  \| If you specify:

  <ul><li> <code>example.com\\/account\\/.\*\\/billing</code> </li></ul> Then LaunchDarkly sends events from views or clicks at any string between <code>account/</code> and <code>/billing</code>, such as <code>[http://example.com/account/12345/billing](http://example.com/account/12345/billing)</code>. <br /> You can test your regular expressions using the tool at [Regular Expressions 101](https://regex101.com/). |
  \| Substring match

  \| This sends an event when the end user accesses a URL, or clicks on an element hosted at a URL with a specific string of text in it.

  \| If you specify:

  <ul><li> <code>[https://www.example.com](https://www.example.com)</code> </li></ul> Then LaunchDarkly sends events from views or clicks at:

  <ul><li> <code>[https://www.example.com/abc](https://www.example.com/abc)</code> </li> <li> <code>[https://www.example.com/def/ghi](https://www.example.com/def/ghi)</code> </li></ul> If you specify:

  <ul><li> <code>your-substring</code> </li></ul> Then LaunchDarkly sends events from views or clicks at:

  <ul><li> <code>example.com/your-substring</code> </li> <li> <code>example.com/username/your-substring/</code> </li> <li> <code>example.com/your-substring/settings</code> </li></ul> Because all of these URLs contain <code>your-substring</code>, clicks on the CSS selectors you specify on each page send events. |
</Accordion>

7. Enter the **Target URL**.
8. (Optional) Click **Add target URL** to track behavior on more than one URL.
9. Select what you want to measure:

* **Count**: the number of times a target was clicked or tapped.
* **Occurrence**: whether or not a target was clicked or tapped.

10. In the [Metric definition](#metric-definition) section, select the following:

    * Analysis method:
      * If you selected **Count** in step 8, select **Average** or a percentile between P50-P99 click rate.
      * If you selected **Occurrence** in step 8, the metric automatically sets this to "Average."
    * per or percentage of **\[analysis unit]**: for clicked or tapped metrics, the analysis unit will usually be "user," "customer," or similar, representing an individual person.

<Frame caption="A clicked or tapped conversion metric.">
  ![A clicked or tapped conversion metric.](https://files.buildwithfern.com/https://launchdarkly.docs.buildwithfern.com/docs/7eabda849f8321fe92b03d8052713b575e7668d1f1745800237dabacd4cdc9e4/assets/images/auto/metrics-event-kind-click.auto.png)
</Frame>

11. Enter a metric **Name**.

12. (Optional) Add a **Description**.

13. (Optional) Add any **Tags**.

14. (Optional) Update the **Maintainer**.

15. 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. You can also [filter the metric events](/home/metrics/event-filters) to specific context attributes or event properties.

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