Page viewed conversion metrics
Read time: 5 minutes
Last edited: Nov 05, 2024
Overview
This topic explains how to create a page viewed metric in LaunchDarkly. Page viewed metrics track how often end users view an element on a page hosted at a specific URL. For example, you might want to track how often customers view an item when its price is discounted different amounts.
For example, you can use page viewed metrics to track:
- How many times a blog post was viewed
- Whether or not customers view a help article
Page viewed metrics must be used with JavaScript-based SDKs.
Page viewed metrics are only compatible with the following 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 page views, 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.
Metric definition
When you create a page viewed conversion metric, you must first decide:
- What do you want to measure:
- Count: the number of times a page was viewed.
- Occurrence: whether or not a page was viewed.
Then, page viewed conversion metric definition options include:
- Analysis method:
- for metrics measuring count, you can you can analyze by:
- Average: "average" is the default analysis method. This method calculates the average number of page views per context. For metrics you plan to use in funnel experiments, you must select "Average."
- Percentile: you can choose between P50-P99, which represent the 50th through the 99th percentile. This method counts the page views per context, then finds the number of page views that fall into the chosen percentile.
- for metrics measuring occurrence, the metric automatically sets the analysis method to "average."
- for metrics measuring count, you can you can analyze by:
- Randomization unit: one or more context kinds, such as "user," "device," or "request," that the metric can measure events from.
For page viewed metrics, the unit aggregation method is automatically set to "sum." To learn more about the metric definition options, read Analysis method and Randomization units.
Create page viewed metrics
To create a page viewed metric:
- Navigate to the Metrics list.
- Click Create metric. The "Create metric" dialog appears.
- Select an event kind of Page viewed.
- 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
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 |
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:
Then LaunchDarkly sends events from views or clicks at any string between 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:
Then LaunchDarkly sends events from views or clicks at:
Because all of these URLs contain |
- Enter the Target URL.
- (Optional) Click Add target URL to track behavior on more than one URL.
- Select what you want to measure:
- Count: the number of times a page was viewed
- Occurrence: whether or not a page was viewed
- In the Metric definition section, select the following:
- Analysis method:
- If you selected Count in step 7, select Average or a percentile between P50-P99 click rate.
- If you selected Occurrence in step 7, the metric automatically sets this to "Average."
- Analysis method:
- per [randomization unit]: For page viewed metrics, the randomization unit will usually be "user," "customer," or similar, representing an individual person.
- Enter a metric Name.
- (Optional) Add a Description.
- (Optional) Add any Tags.
- (Optional) Update the Maintainer.
- 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 Guarded rollouts.
You can also use the REST API: Create metric