In Optimizely X, URL Targeting is a property of a Page. You can access it in the following ways:
Want to see this feature in action? Check out our two-minute video on URL Targeting:
URL Match Types
In the URL Targeting menu, you can enter URL match specifications that tell Optimizely where the experiment should run.
Each URL match you enter can be one of four types:
- Simple Match: This is the default match type and is generally useful when testing a single page.
- Exact Match: This match type should be used only when adding query parameters or hash parameters to the URL will significantly change how the page displays for visitors. (If you want to target visitors who are using a certain query parameter, use an Audience Condition instead.)
- Substring Match: This will match specific strings of texts within a URL. It's useful for experiments that change the same element sitewide, or across many pages.
- Regular Expressions: These can be used to target complicated URL structures that aren't easily captured by the other URL match types. If this doesn't work for you, you may want to use custom tags on the pages you intend to target.
It is worth noting that Regular Expressions are case-sensitive, while Simple, Substring and Exact Matches are not case-sensitive.
We describe the match types in more depth below.
Simple match is the default URL match type, and it's ideal for running experiments on single pages. It will run when visitors land on a URL, even if it has the following variations:
Simple match will ignore these changes and run your experiment on the page, because those modifications usually don't change the way your page displays.
To use simple match, just enter the full URL (the absolute URL, not a relative URL like
/products/general.html) of the page you want to target. Here's an example of the common variants that will pass a simple match:
The above examples match because they run on the same page as the original URL. Even adding query (?) or hash (#) parameters doesn't generally change the page.
What won't match the original? Some examples of changes that simple match WON'T ignore are:
- Changes in subdomain (aside from www)
- Adding .html or other extensions
- Adding or changing subdirectories
See below for some examples:
In the above example, these would not match the original URL because they are not the same page. Specifically:
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 unique to a particular visitor’s information. A sample Account URL would be:
Setting it up:
Identify which portion of the account page URL is static and which portion is dynamic.
In this case, the URL to the left of the “?” will always be the same, while the parameters to the right of the “?” will be unique to each user.
In the URL targeting, select “Simple match” from the dropdown, and add the account URL, excluding all query string parameters. In this case it would be
A simple match ignores anything to the right of the question mark in the URL (ie. all query string parameters). In the example above, ?account_id=1234&location=san_francisco would be ignored, which is what we want since these will be dynamic.
This setup ensures that your experiment will run on all account pages, regardless of the unique customer who is viewing the page.
Example: Visitors who land on only two of many landing pages
You have around 10 landing pages live at any one time, and you want to run an A/B test on just 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 the visitor came from.
Setting it up:
Identify what the two specific URLs look like and how they differ from other landing page URLs on your domain.
In the URL targeting, select “Simple match” from the dropdown and add the URL of the first landing page.
Click the green “+” icon and add the URL of the second landing page as a “Simple match.”
A simple match ignores anything to the right of the question mark in the URL (ie. all query string parameters). This set-up ensures the experiment will only run if the visitor lands on the first landing page URL or the second landing page URL.
You may also find simple match handy to exclude certain URLs from a substring match that targets many pages at once (see below for more on substring match).
In the above example, the examples including
://www.example.com/ignorethispage are excluded because the targeting is set to exclude that URL as a simple match.
Exact match URLs will run an experiment only when users load the exact URL.
Like simple match, exact match will ignore trailing slashes, http/https protocols, and www. Also like simple match, exact match will not ignore subdirectories, extensions, or changes in subdomains (
www.example.com/blog). See our simple match description above for more information.
Unlike simple match, exact match will 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.example.com would be included because Exact match accepts these common variations. The following would be excluded:
If you specify a particular query or hash parameter, exact match will allow only that exact parameter into the experiment.
Exact match may come in handy when excluding 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 referred to as a substring, and can be present anywhere in the URL.
For example, if you wanted to target an element on all product pages, look for a part of your URL that is consistent across all of those pages. If the substring '/products' is in every product page, run a substring match on '/products'.
Substring match ignores trailing slashes and http/https protocols. But it doesn't ignore subdomains (including 'www'), subdirectories, extensions, or changes to query/hash parameters.
Unlike simple and exact match, substring match doesn't need a full URL to match. You can substring match on a word, a query parameter, a subdirectory, or any other substring that might appear somewhere in the URL.
This makes substring match ideal for targeting entire categories of pages, or targeting your entire site (for example, to make a change to your global navigation menu).
Here's how a substring match will target the experiment when you include www (or another subdomain):
In the above example, only the URLs that include the string
www.example.com are included.
But notice that when you remove the subdomain or 'www', it will target any page on your domain where the snippet is implemented.
You can target an entire category of pages by including the directory that appears in their URL:
In the above example, all strings that include the string
You can also target a certain parameter anywhere it appears:
In the above 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 of your 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 the product page URLs look similar (an example of one might be:
http://www.patagonia.com/us/product/...cket?p=84673-0, where everything after “product” is dynamic).
Setting it up:
Identify a common URL structure for all of your product pages that is unique to those pages.
In the URL targeting section, choose substring match and enter the portion of the URL that is guaranteed to be the same across the desired set of pages.
For example, use a substring match for
This will ensure that the experiment will run on any URL that has the string
patagonia.com/us/product present in the full URL. Any values can be added before of after this string and the match will still apply.
If your product pages do not have a common URL structure, you may need to use custom tags instead of a substring match.
Example: Run sitewide except for a certain sub-set of pages
You want to run a sitewide navigation bar change across all the main pages on your site. However, there is a sub-set of “news” pages that do not follow your site’s standard layout, so you want to exclude these page from the experiment.
You know that the “news” pages all have a URL that begins with
http://www.yellowpages.com/news. The dynamic topic and article name are appended after “news/”.
For example, a full URL would be:
Setting it up:
Start with the bigger group of pages that you do want to include in the experiment. In this case, you would set a substring match to www.yellowpages.com to ensure the experiment runs site-wide.
Now, you will want to identify a common URL structure for all of the pages that should be excluded from the test.
In the URL targeting section, choose “Exclude URLs,” and select “Substring match” from the dropdown menu. Enter the portion of the URL that is guaranteed to be the same across the specific set of pages.
In the example above, a substring match to
The experiment will run on page on your domain that have the substring
www.yellowpages.com, but NOT any pages that have the string
When using “Exclude” in URL targeting, both positive and negative conditions must be met. In other words, the visitor must land on a page that matches the included condition but 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 all pages on your site where the snippet is implemented, use a Regular Expression Match and enter
.* as your match condition.
While it's impossible to cover all of the different possibilities this allows for here, we'll provide a small sample.
Let's say 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 in order to trigger your experiment using Optimizely. For example, the regular expression 'x=y' will match all of the following pages:
If you're trying to target a series of pages that can't be included neatly in a substring match or RegEx, consider adding Custom Tags to the pages you want to target, and targeting visitors who land on a page containing that tag. Note that Custom Tags are an Audience condition, not a URL Targeting condition, but they can be used to accomplish the same purpose.