URL Targeting

URL targeting rules determine which pages your experiment is active on. A visitor must be on a page that matches at least one of your URL rules for the experiment to run. If no URL rules match the current page, the snippet skips the experiment entirely: the visitor sees the default experience and is not enrolled.

URL rules live on the experiment builder's Targeting step: each rule has a match type, and the Test a URL box lets you verify them.

Where to configure URL rules

URL rules are configured in Step 1: Targeting of the experiment builder. When you create a new experiment, the first thing you will be asked to do is define where the experiment runs. You can add one or more URL rules, each with its own match type and value.

Match types

A vs B's matching engine supports six match modes in total. The experiment builder only offers five of them when you add a new rule: Exact, Path, Substring, Pattern, and Regular Expression. The match type determines how the rule value is compared to the current page URL.

Exact Match

Exact matching requires the full URL, including protocol, domain, path, and query string, to match. Differences that don't change the page are ignored: the case of the domain, a trailing slash, a #fragment, a default port, and the order of query parameters.

Plain text
Rule value:  https://example.com/pricingCondition:   MatchesMatches:     https://example.com/pricing             https://example.com/pricing/Does not:    https://example.com/pricing?plan=pro             https://www.example.com/pricing
Plain text7 lines

Best for: Targeting a single, stable page with a known, unchanging URL.

Path Match

Path matching compares only the pathname on each side, and ignores everything else: the protocol, the domain, the query string, and a trailing slash. You can write the rule as a bare path or as a full address; both are reduced to just the path before comparing.

Plain text
Rule value:  /pricingCondition:   MatchesMatches:     https://example.com/pricing             https://example.com/pricing/             https://example.com/pricing?plan=pro             https://staging.example.com/pricingDoes not:    https://example.com/pricing/pro             https://example.com/pricing-page
Plain text9 lines

Best for: Targeting one page's path when you don't care about a query string or a trailing slash, for example a single checkout confirmation page at /checkout. It's also the right choice when the domain shouldn't matter, such as the same page served on a staging subdomain.

Path Match ignores the domain entirely

Path Match strips the domain from both sides before comparing. So a rule written as /pricing matches that path on ANY domain the snippet runs on, including a staging or preview host. Use Exact Match instead if the domain needs to match too.

Substring Match

Substring matching checks whether the value you enter appears anywhere in the full URL string, including the domain, path, and query string. Type just the piece you're looking for: it doesn't need https://. A value with a space is flagged, because a page address never contains one.

Plain text
Rule value:  checkoutCondition:   MatchesMatches:     https://example.com/checkout             https://example.com/checkout/payment             https://example.com/express-checkout             https://example.com/cart?step=checkoutDoes not:    https://example.com/products             https://example.com/account
Plain text9 lines

Best for: Targeting pages where a keyword appears in the URL but the full path varies or is unpredictable.

Pattern Match

Pattern matching checks the full URL against a value that can contain two wildcard characters. * stands for any sequence of characters, including none, and ? stands for exactly one character. Unlike Substring, the pattern must account for the whole address from start to end. So a pattern with no wildcards behaves like Exact Match.

Plain text
Rule value:  https://example.com/product/*Condition:   MatchesMatches:     https://example.com/product/123             https://example.com/product/red-shoesDoes not:    https://example.com/product             https://example.com/products/123
Plain text7 lines
Plain text
Rule value:  https://example.com/page?.htmlCondition:   MatchesMatches:     https://example.com/page1.html             https://example.com/pageA.htmlDoes not:    https://example.com/page12.html             https://example.com/page.html
Plain text7 lines

Best for: A quick wildcard pattern across a whole URL, when Substring is too loose but full Regex is more than you need.

Regular Expression Match

Regex matching tests the full URL against a JavaScript regular expression you provide. This is the most powerful option and lets you express complex patterns with a single rule. Write the pattern as bare regex source (\/product\/[0-9]+) or as a /pattern/flags literal (/\/product\/[0-9]+/i): both forms work.

Plain text
Rule value:  /\/product\/[0-9]+/Condition:   MatchesMatches:     https://example.com/product/123             https://example.com/product/9999Does not:    https://example.com/product/shoes             https://example.com/products
Plain text7 lines
Plain text
Rule value:  /\/(checkout|cart)(\/|$)/Condition:   MatchesMatches:     https://example.com/checkout             https://example.com/checkout/payment             https://example.com/cartDoes not:    https://example.com/products
Plain text7 lines

Best for: Dynamic URL patterns, numeric IDs in paths, or targeting multiple specific paths with one rule.

A sixth mode exists, but only on old experiments

A vs B's matching engine also has a Simple mode, an older pathname-prefix match. It is no longer offered when you add a new URL rule. An experiment built before Simple was retired may still carry one; if you open it in the builder, that rule shows as Path prefix. It still works exactly as before: it checks whether the current page's path (or full address, if you wrote the rule as one) starts with the rule's value. It just isn't in the dropdown for new rules, so a page targeted with a category prefix today is built with Substring or Pattern instead.

Matches and Does Not Match

In the experiment builder, one shared dropdown, URL matches / does not match these URL(s), applies to every rule in the set at once. You cannot mix Matches and Does Not Match rules in the same experiment from the dashboard today. It's an all-or-nothing choice for the whole rule list.

Matches (the default): the experiment runs when the current page satisfies at least one of your rules.

Does Not Match: the experiment runs on every page except the ones your rules describe. Use this when an experiment should run site-wide except for a few pages, for example every page except /admin and /internal.

Multiple rules use OR logic

Add more than one rule while Matches is selected, and the rules combine with OR logic. The experiment runs if the current page satisfies ANY of them.

Plain text
Rule 1: Substring / products    → MatchesRule 2: Substring / collections → MatchesResult: The experiment runs on any page containing "products"        OR any page containing "collections"
Plain text5 lines

Switch the shared dropdown to Does Not Match instead, and multiple rules combine the other way. The experiment is blocked from a page that satisfies ANY of them, and runs everywhere else. That's the correct way to read "except these pages," not OR.

Mixed rule sets exist, just not in the dashboard yet

A vs B's evaluation engine can combine Matches and Does Not Match rules in one experiment: run on /shop but not /shop/sale, in a single rule set. The public API accepts that shape too. The dashboard's Targeting step just doesn't expose a way to build it yet, since its one dropdown sets the condition for every rule at once.

Info

URL targeting is evaluated before any audience conditions. If the current page does not match any URL rule, the snippet skips audience evaluation entirely and does not enroll the visitor.

Was this helpful?