About clicked or tapped metrics
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
Example metric in SQL
Some customers find it helpful to think about LaunchDarkly metric calculations in terms of SQL statements. The following examples show how different click or tap metrics could be represented as SQL expressions, using example table and column names to represent metric components:eventsis a table that stores all of the metric events on which the metric is defined.exposuresis a table that contains flag evaluation data collected during an experiment or guarded rollout that uses the metric.user_idis a table column that represents the context both for the metric analysis unit and for the randomization unit used in the experiment or guarded rollout. This example uses the “user” context kind, but a metric can use other context kinds, such as “account,” “session,” or “device.”aggregation_funcrepresents the aggregation function that corresponds to the analysis method you select, such asAVGfor average analysis orPERCENTILE_CONTfor percentile analysis.
Prerequisites
Clicked or tapped metrics are only compatible with the following JavaScript-based client SDKs:- Electron
- JavaScript
- Node.js (client-side)
- React Web
- Vue
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-classnamebutton.example-button.example-button, .example-button-alt
Metric definition
When you create a clicked or tapped conversion metric, you first choose the metric aggregation type:- Count uses sum aggregation to measure the total number of times a context clicks a target.
- Occurrence (Percent) uses average aggregation to measure whether or not a context clicks a target. This option automatically sets the metric analysis type to average, to measure the percent of units that click a target for a given flag variation.
- Average: The default Average analysis method calculates the average number of clicks per context for a given flag variation. 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 per context, then finds the number of clicks that fall into the chosen percentile.
Create clicked or tapped metrics
To create a clicked or tapped metric:- Open the Data section and navigate to the Metrics list.
- Click Create metric. The “Create metric” dialog appears.
- If you use warehouse native metrics, you can select either LaunchDarkly hosted or Warehouse native. Select LaunchDarkly hosted.
- Select an event kind of Clicked or tapped.
- Enter one or more CSS selectors in the Click target(s) field. If you include multiple CSS selectors, separate them with commas.
- Specify the Target type you want to track behavior on. Expand the section below to view the four types of URL matching.
Expand URL matching options
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:Then LaunchDarkly sends events from views or clicks at:If you specify:Then LaunchDarkly sends events from views or clicks at: |
| 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:Then LaunchDarkly sends events from views or clicks at:Views and clicks at https://www.example.com/login and https://www.example.com#signin 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:
account/ and /billing, such as http://example.com/account/12345/billing.You can test your regular expressions using the tool at Regular Expressions 101. |
| 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:Then LaunchDarkly sends events from views or clicks at:If you specify:
your-substring, clicks on the CSS selectors you specify on each page send events. |
- Enter the full URL or search pattern in Target URL.
- (Optional) Click Add target URL to track clicks on more than one URL target.
- Choose either Count or Occurrence (Percent) in the Metric definition section to configure the aggregation type. The window populates a full metric definition using default values.
- Use the [analysis unit] menu to change or add analysis unit context kinds. For clicked or tapped metrics, the analysis unit will usually default to “user,” “customer,” or similar, representing an individual person. Only context kinds marked as available for experiments and guarded rollouts appear as options. To learn more, read Mark context kinds available for experiments.
-
If you chose Count as the aggregation type, choose either Average or a percentile between P50-P99 click rate to specify the metric analysis method.

A clicked or tapped conversion metric.
- Enter a metric Name.
- (Optional) Add a Description.
- (Optional) Add any Tags.
- (Optional) Update the Maintainer.
- Click Create.
You can also use the REST API: Create metric