- Optimizely Web Experimentation
- Optimizely Performance Edge
- Choose which URLs a visitor needs to use to determine whether the experiment will run
- Use the URL match types available in Optimizely Web Experimentation or Optimizely Performance Edge: simple, exact, substring, and regular expression (RegEx)
URL Targeting at a glance
After you create your variations in the editor, you tell Optimizely Web Experimentation or Optimizely Performance Edge where the experiment should run on your site. Use the match types described here to target a specific URL or a group of URLs.
Use simple match when testing a single page
Use exact match only when adding query parameters or hash parameters to the URL significantly changes how the page displays
Use substring match for experiments that change one element across multiple pages or your entire site
Use regular expression to target complicated URL structures
What to watch out for
Make sure the Optimizely Web Experimentation or Optimizely Performance Edge snippet is implemented on all pages you target
URL targeting specifies the pages where an experiment or campaign should run. You can target specific URLs or groups of URLs, depending which match type you select.
Optimizely Performance Edge is a lightweight experimentation product that delivers significantly faster performance than previous versions of Optimizely Experimentation. It does this by relying on a streamlined "microsnippet" which limits the range of available features.
Optimizely Performance Edge and Optimizely Web Experimentation handle URL targeting the same way, so all information contained in this article applies to experiments created with either version of Optimizely Experimentation.
Find URL targeting
To find URL targeting:
From the Experiments page, select your experiment.
In the pane on the left, select Targeting.
In the Target By dropdown list, select URL.
Configure URL targeting for your experiment.
To edit a site-wide element, like a button in the navigation bar or a CTA in the footer, see Edit elements that display site-wide.
You can also learn how to build an experiment in our Optimizely Academy. Have a question about targeting? Head over to the Optimizely Experimentation questions on Stack Overflow to join the discussion.
Test URL(s) to double-check your targeting
To check your targeting conditions and ensure that your experiment runs on the expected pages, use Test URL(s), which is part of the targeting modal. Test URL(s) tells you whether the sample URLs you enter match the URL targeting conditions. A match means the experiment will run. A non-match means the experiment will not run.
Test URL(s) lets you confirm whether a URL targeting condition or pageview goal will correctly target the URLs you intend. Click the "+" icons to add as many sample URLs as you want to validate. Try checking for URLs that you do and do not expect to match in your experiment.
URL match types
Within an experiment, on the Targeting page, enter the URL you want to use and add URL match specifications that tell Optimizely Web Experimentation or Optimizely Performance Edge where the experiment should run.
Each URL match you enter can be one of these types:
Simple match – This is the default match type. It is useful for testing a single page.
Exact match – Use only when adding query parameters or hash parameters to the URL significantly changes how the page displays for visitors. To target visitors who are using a certain query parameter, use an audience condition instead of an exact match.
Substring match – Use to match specific strings of text within a URL. It is useful for experiments that change the same element site-wide or on multiple pages.
Regular expression – Use to target complicated URL structures that are not easily captured by the other URL match types.
Simple match is the default URL match type, and it is ideal for running experiments on single pages. A simple match runs when visitors land on a URL, even if it has these variations:
Adding or changing a query parameter (like
Adding or changing a hash parameter (like
Changing protocol between http:// and https:// (like
Adding or removing a trailing slash at the end of your URL (like
Adding or removing www from your URL (like
Simple match ignores these changes (because they usually do not change the way your page displays) and runs your experiment on the page.
To use simple match, enter the full URL of the page you want to target—the absolute URL, not a relative URL like
/products/general.html. The following examples show common variants that will pass a simple match:
These examples match because they run on the same page as the original URL. Even adding query (?) or hash (#) parameters does not generally change the page.
What will not match the original? Simple match will not ignore changes in subdomain (aside from www), adding .html or other extensions, or adding or changing subdirectories.
The following examples will not pass a simple match:
These examples will not match the original URL because they are not the same page:
https://www.atticandbutton.comdoes not have the same extension as
https://www.atticandbutton.usdoes not have the same subdirectory as
https://www.blog.atticandbutton.usdoes not have the same subdomain as
Example: User account page with many dynamic/unique query string values
You want to run an experiment on a “My Account” page for all of your customers. However, every account URL includes query parameters that are unique to a particular user’s information. A sample account URL would be:
To set it up:
Identify the static and dynamic portions of the account page URL.
In this case, the URL to the left of the “?” is always the same (static), and the parameters to the right of the “?” are unique to each user (dynamic).
In URL targeting, select Simple match from the dropdown list. Add the account URL, excluding all query string parameters (in this case,
A simple match ignores anything to the right of the question mark in the URL (all query string parameters). In this case,
?account_id=1234&location=san_franciscowould be ignored, which is what we want since this is the dynamic portion of the account page URL.
This setup ensures that your experiment runs on account pages, regardless of the unique user who is viewing the page.
Example: Visitors who land on only two of many landing pages
You have about 10 landing pages live at any one time, and you want to run an A/B test on only two of these pages. You know there will always be unique UTM/query parameters added to the URL from paid search traffic, but you want the experiment to run regardless of which campaign a visitor comes from.
To set it up:
Identify the two specific URLs you want to test and how they differ from other landing page URLs on your domain.
On the Targeting page of your experiment, select Simple match from the dropdown list and add the URL of the first landing page.
Click the “+” icon and add the URL of the second landing page as a Simple match.
Because a simple match ignores anything to the right of the question mark in the URL (all query string parameters), this set-up ensures the experiment will run only if a visitor lands on the first landing page URL or the second landing page URL.
Simple match may also be handy for excluding certain URLs from a substring match that targets many pages at once.
In these examples, those that include
www.atticandbutton.us/about are excluded because the targeting is set to exclude that URL as a simple match.
Exact match runs an experiment only when users load the exact URL.
Like simple match, exact match ignores trailing slashes at the end of your URL, http/https protocols, and www. Also, like simple match, exact match does not ignore subdirectories, extensions, or changes in subdomains (
www.atticandbutton.us compared to
Unlike simple match, exact match does not ignore changes to query or hash parameters.
Enter a full URL when using exact match—the absolute URL, not a relative URL like
In this example,
https://www.atticandbutton.us are included because exact match accepts these common variations.
The following URLs are excluded:
http://www.atticandbutton.us?query=truebecause it includes a query parameter.
http://www.atticandbutton.us/cartbecause it is not the same subdirectory.
http://blog.atticandbutton.usbecause it is not the same subdomain.
If you specify a query or hash parameter, exact match allows only that exact parameter into the experiment.
Exact match may come in handy when you want to exclude specific query or hash parameters from a simple match.
Substring match runs an experiment when the URL contains a set of characters that you specify. This set of characters is called a substring and can be present anywhere in the URL.
For example, if you want to target an element on all product pages, look for a part of your URL that is consistent across all product pages. If the substring "/products" is in every product page, run a substring match on "/products".
Substring match ignores trailing slashes that display at the end of your URL and http/https protocols, but it does not ignore subdomains (including 'www'), subdirectories, extensions, or changes to query or hash parameters. To match a substring that includes a trailing slash (if you have a page like "/example" and need to match "/ex/" instead), use a regex match instead of substring.
Unlike simple and exact match, substring match does not need a full URL to match. You can substring-match on a word, query parameter, subdirectory, or any other substring that might display somewhere in the URL. This makes substring match ideal for targeting entire categories of pages or your entire site (for example, to make a change to your global navigation menu).
The following image shows how a substring match targets the experiment when you include www (or another subdomain):
In this example, only the URLs that include the string
www.atticandbutton.us are included.
But when you remove the subdomain or "www", the substring match targets any page on your domain where the snippet is implemented:
You can target an entire category of pages by including the directory that displays in their URL:
In this example, all strings that include the string
accessories are included.
With substring match, you can also target a certain parameter anywhere it displays:
In this example, all the strings that include the string
utm_campaign=springpromo are included.
Example: Testing on categories of pages
You want to run an experiment on all product detail pages, but you want to be sure that your changes do not also show up on other pages of the site. You know that all product detail page URLs look similar (for example,
http://www.atticandbutton.us/product/scarf?p=4673, where everything after “product” is dynamic).
To set it up:
Identify a common URL structure for all of your product pages that is unique to those pages.
On the Targeting page of your experiment, select Substring match from the dropdown list and enter the portion of the URL that is guaranteed to be the same across the desired set of pages (for example,
This ensures that the experiment runs on any URL that has the string
atticandbutton.us/product in the full URL. The substring match applies even if values are added before or after this string.
Example: Run site-wide, except for a certain subset of pages
You want to run a site-wide navigation bar change across all the main pages on your site. However, a subset of “news” pages do not follow your site’s standard layout, so you want to exclude these “news” pages from the experiment.
You know that the “news” pages all have a URL that begins with
www.atticandbutton.us/news. The dynamic topic and article name are appended after “news/”.
For example, a full URL might be:
To set it up:
Start with the bigger group of pages that you do want to include in the experiment. In this case, set a substring match to
www.atticandbutton.usto ensure the experiment runs site-wide.
Identify a common URL structure for all of the pages that should be excluded from the experiment.
On the Targeting page of your experiment, add another condition and select Substring match from the dropdown list. Enter the portion of the URL that is guaranteed to be the same across the set of pages you want to exclude (in this example,
The experiment runs on pages on your domain that have the substring
www.atticandbutton.us, but not pages that have the string
When you exclude URLs in URL targeting, both positive and negative conditions must be met. In other words, to be included in the experiment, a visitor must land on a page that matches the included condition and does not match the excluded condition.
Regular expression match
Expert users can use regular expressions (RegEx) to specify a set of pages on which an experiment should run. For example, to target pages on your site where the snippet is implemented, use a regular expression match and enter
.* as your match condition.
You cannot cover all of the possibilities that regular expressions allows. Here is a small sample.
Suppose that you want to target your experiment to pages in your
/products/shirts sections, but no others. You might write a regular expression that looks like this:
Your expression does not need to match the full URL to trigger your experiment using Optimizely Web Experimentation or Optimizely Performance Edge. For example, the regular expression 'x=y' will match the following pages:
When we evaluate a URL using the RegEx match type, Optimizely Web Experimentation or Optimizely Performance Edge strips the Optimizely Experimentation query parameters. For example, if you are trying to create a RegEx to match
http://www.atticandbutton.us, the added Optimizely Experimentation query parameters might look like this:
The stripped URL we evaluate would be
http://www.atticandbutton.us/?. Optimizely Web Experimentation and Optimizely Performance Edge do not remove the
/? when stripping the Optimizely Experimentation query parameters due to inconsistent behavior among browsers.
To match the URL
http://www.atticandbutton.us, you may want to include matching for the trailing
/?. You could use
example\.com\/?\??$ to match with and without the trailing forward slash and question mark and to not match if there is an actual query parameter in the URL, like a UTM campaign.