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:
LaunchDarkly’s observability features include a session replay plug-in that automatically tracks the URLs a user visits during a session recording. You can use the session replay visited-url property to filter the sessions displayed in the Sessions tab of the LaunchDarkly UI. However, you cannot use this property as an event for creating new metrics.
This topic describes how to instrument page viewed events and metrics that you can use to create experiments or guarded rollouts.
Page viewed 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 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.
When you create a page viewed conversion metric, you must first decide:
Then, page viewed conversion metric definition options include:
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 Analysis units.
To create a page viewed metric:

You can connect the metric to an experiment or guarded rollout to monitor the impact of a flag change.
You can also use the REST API: Create metric