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.

Creating a pageview metric: enter the URL that counts as a conversion and pick how strictly to match it.

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 you want to match against. The value you enter depends on which match mode you choose in the next step.

6

Choose a match mode

Select one of the six match modes: Simple, Exact, Path, Substring, Pattern, or Regex. A new metric starts on Path, the strictest reading of a goal page, and switching to another mode is one click. See the descriptions and examples below.

7

Save the metric

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

Match modes

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

ModeIn plain English
SimpleThis page (ignores tracking tags and trailing slashes)
ExactOnly this exact address
PathThis page's path
SubstringAny address containing this text
PatternAddresses matching a pattern with *
RegexFull regular expression match

Simple

Simple matching is the forgiving choice. It ignores anything after a ? (tracking tags like utm_source), anything after a #, and a trailing slash, on both what you enter and the address the visitor is on. Pages underneath the one you enter count too.

Enter a path such as /thank-you and it is compared with the page's path. Enter a full address such as https://example.com/thank-you and it is compared with the whole address, so another domain never matches.

Plain text
Pattern:  /thank-youMatches:  /thank-you          /thank-you/          /thank-you?order=123          /thank-you#receipt          /thank-you/detailsDoes not: /checkout/thank-you          /products
Plain text8 lines

When to use: Almost always. It is the mode to reach for when you want "this page counted", whatever tracking tags happen to be on the link.

Exact

Exact matching requires the full address to match character for character. The protocol, domain, path, query string, and any trailing slash must all be identical.

Plain text
Pattern:  https://example.com/order-confirmationMatches:  https://example.com/order-confirmationDoes not: https://example.com/order-confirmation?id=456          https://example.com/order-confirmation/
Plain text4 lines

When to use: When one stable address represents the conversion and you want nothing else to trigger it. Be aware that a single tracking tag on the link stops it matching.

Path

Path matching compares only the path part of the address. The domain, the query string, anything after a #, and a trailing slash are all ignored. Unlike Simple, a deeper page does not count: the path has to be the same one.

Path is what a new metric starts on, and it is the safest choice for a goal page: a metric for /cart fires on /cart and nowhere else, never on a deeper page and never on an address that merely contains that text.

Plain text
Pattern:  /order/confirmationMatches:  /order/confirmation          /order/confirmation/          https://example.com/order/confirmation?id=456Does not: /order/confirmation/print          /order
Plain text6 lines

When to use: When the same page is reachable on more than one domain, such as a staging site and a live site, and you want one metric to cover both.

Substring

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

Plain text
Pattern:  confirmationMatches:  https://example.com/order-confirmation          https://example.com/account/confirmation?ref=email          /booking-confirmationDoes not: /thank-you          /success
Plain text6 lines

When to use: When the word that identifies a conversion page appears somewhere in the address but the rest of the path varies.

Pattern

Pattern matching lets you write the address with wildcards. * stands for any run of characters, including slashes, and ? stands for exactly one character. The whole address has to match from start to end, so remember a * at the end if the page can carry tracking tags.

Plain text
Pattern:  https://example.com/order/*/confirmation*Matches:  https://example.com/order/1234/confirmation          https://example.com/order/1234/confirmation?ref=emailDoes not: https://example.com/order/confirmation          https://example.com/basket
Plain text5 lines

Patterns may contain letters, digits, and the characters / - _ . : & = % plus the * and ? wildcards. Anything else, such as a space or a bracket, is not a valid pattern and the metric will not fire.

When to use: When the address contains something that changes every time, like an order number, and you do not want to write a regular expression.

Regex

Regex matching tests the full address against a JavaScript regular expression. This is the most powerful mode and matches complex addresses, optional segments, or several paths with one rule.

Plain text
Pattern:  \/order\/(confirmation|success)(\?.*)?$Matches:  /order/confirmation          /order/success          /order/confirmation?id=789Does not: /order/pending          /order/
Plain text6 lines
Regex syntax

Write the expression on its own, as in \/order\/(confirmation|success). Matching is case-sensitive by default. To pass flags, wrap the expression in slashes and put the flags after the closing one: /\/order\/confirmation/i matches whatever the capitalisation. The expression is tested against the whole address, not just the path, so it can match on the domain or the query string too. An expression that is not valid never matches, and nothing else on the page is affected.

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. Every match sends a conversion event to A vs B, even repeat visits to the same matching page in one session.

One conversion per visitor

Like all metric types, a pageview metric's conversion-rate result still counts each visitor at most once. Visiting the same matching URL multiple times only moves your count once, when the results are calculated: 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.

Was this helpful?