URL Targeting – Choosing Which Pages an Experiment Runs On
Learn how to use URL targeting conditions to control exactly which pages an experiment runs on.
3 min read
URL targeting decides which pages an experiment is allowed to run on. It is the most important targeting rule you will set, because a test that fires on the wrong pages produces data that looks valid and is not.
You configure it on the experiment’s Settings tab. Drag a condition from Available Conditions into the Target Area, then enter the URL to match against.
The available conditions
- equals — the URL must match exactly. The strictest option, and the right one for a single specific page.
- starts with — matches everything beneath a path.
https://example.com/blogcatches every article under/blog. - contains — matches if the string appears anywhere in the URL. Useful for a path fragment that appears at varying depths.
- ends with — matches the end of the URL. Handy for file extensions or a repeated trailing segment.
- matches regex — a regular expression, for cases the simple conditions cannot express.
- not equals — excludes one exact URL.
- does not contain — excludes every URL containing a string. This is how you keep a test off a section of the site.
Query strings and fragments
Real URLs arrive with campaign parameters, session ids and anchors attached. An equals rule against a clean URL will not match ?utm_source=newsletter, and this is the single most common reason an experiment appears to receive no traffic.
If your traffic carries parameters, prefer starts with or contains over equals.
Combining rules
You can add several conditions to one experiment. Use positive conditions to define where the test should run and negative ones to carve out exceptions — for example starts with /products to cover the catalogue, plus does not contain /products/clearance to keep it off the sale section.
Remove a rule by clicking the cross on its chip in the Target Area. Changes take effect on the next generation of your site’s runtime file, not instantly in an already-open browser tab.
Checking that it works
Test the rule before you trust it:
- 1Open a page that should match and confirm the experiment activates.
- 2Open a page that should not match and confirm it does not.
- 3Open a matching page with campaign parameters appended, as your real traffic will.
If an experiment stops receiving traffic after a site change, URL targeting is the first thing to check: a URL structure change silently stops matching rules that were correct when they were written.
Notes
- With no URL targeting rule at all, the experiment is not restricted by URL.
- Rules are matched against the full URL as the browser sees it.
- Editing targeting mid-run changes which visitors enter the test, and the periods before and after are not directly comparable.