/Docs

Pageview Metrics

A pageview metric converts when a visitor navigates to a URL that matches a pattern you define. It is the most natural way to measure conversions that are represented by reaching a specific page — like a confirmation page after checkout, a thank-you page after signing up, or any section of your site that indicates meaningful engagement.

What pageview metrics track

Pageview metrics listen for URL changes as the visitor navigates your site — including both full page loads and client-side navigation in single-page applications. When the URL changes, A vs B checks whether the new URL matches the pattern you defined. If it does, and the visitor has not already converted on this metric, a conversion is recorded.

How to create a pageview metric

1

Go to the Metrics page

From your project dashboard, click Metrics in the left navigation.
2

Click New Metric

Click the New metric button. The metric creation form will open.
3

Choose Pageview as the type

Select Pageview from the metric type options.
4

Give it a name

Enter a descriptive name such as Thank You Page Visit, Order Confirmation, or Account Dashboard Reached.
5

Enter a URL pattern

Enter the URL pattern you want to match against. The value you enter depends on which match type you choose in the next step.
6

Choose a match type

Select one of the four match types: Simple, Exact, Substring, or Regex. See the descriptions and examples below.
7

Save the metric

Click Save. The metric is now available to attach to experiments.

Match types

A vs B offers four ways to match URLs. Choose the one that best fits the pattern of the page you want to track.

Simple (pathname prefix)

Simple matching checks whether the URL's pathname starts with the value you enter. It is the most forgiving match type and works well when you want to capture any page under a particular path.

text
1Pattern: /thank-you
2Matches: /thank-you
3 /thank-you?order=123
4 /thank-you/details
5Does not: /checkout/thank-you
6 /products

When to use: Tracking any page within a section, like all pages under /account/ or any URL that starts with /confirmation.

Exact

Exact matching requires the full URL to match precisely. The protocol, domain, path, and query string must all match exactly.

text
1Pattern: https://example.com/order-confirmation
2Matches: https://example.com/order-confirmation
3Does not: https://example.com/order-confirmation?id=456
4 https://example.com/order-confirmation/

When to use: When you have a single, stable URL that represents a conversion and you want no other URL to trigger it.

Substring

Substring matching checks whether the value you enter appears anywhere in the full URL — including the protocol, domain, path, and query string.

text
1Pattern: confirmation
2Matches: https://example.com/order-confirmation
3 https://example.com/account/confirmation?ref=email
4 /booking-confirmation
5Does not: /thank-you
6 /success

When to use: When the key word or phrase that identifies a conversion page appears somewhere in the URL but the full path may vary.

Regex

Regex matching tests the full URL against a JavaScript regular expression. This is the most powerful option and lets you match complex patterns, optional segments, or multiple paths with one rule.

text
1Pattern: /\/order\/(confirmation|success)(\?.*)?$/
2Matches: /order/confirmation
3 /order/success
4 /order/confirmation?id=789
5Does not: /order/pending
6 /order/
Regex syntax
Enter the pattern without surrounding slashes. The pattern is tested using JavaScript's RegExp constructor with no flags by default, so matching is case-sensitive. If you need case-insensitive matching, use a non-capturing group at the start: (?i) is not supported, but you can use character classes like [Cc]onfirmation.

How the snippet detects pageviews

The snippet monitors URL changes using two mechanisms. For traditional page loads, it checks the URL when the page first loads. For single-page application navigation, it monitors history.pushState, history.replaceState, and the popstate event so that client-side route changes are detected without a full page reload.

Each time the URL changes, the snippet evaluates all active pageview metrics against the new URL. If the pattern matches and no conversion has been recorded for this visitor on this metric, it sends the conversion event to A vs B servers.

One conversion per visitor

Like all metric types, pageview metrics record at most one conversion per visitor. Visiting the same matching URL multiple times only counts once. This reflects the real meaning of "this visitor converted" rather than counting return visits.

Tip
If you want to track the number of times a page is visited (not just whether a visitor visited it at all), use a custom event with avsb.track.event() inside your analytics layer instead of a pageview metric.