For many experiments you can use Optimizely's URL Matching feature to specify which page or pages the experiment should run on. However, on some sites, you may wish to run an experiment on a group of pages that are not easily captured in a substring or regular expression. This article explains how you can easily configure an experiment to run on a group of pages like this. We'll start with an example:
Let's consider an ecommerce site in which the product detail pages all have urls like this:
If you wanted to run an experiment across all product pages, there's no obvious way of capturing all such URLs in a regular expression or substring.
Step 2 - Set your Optimizely experiment targeting as follows:
Note here that we've set the URL matching to "example.com" and that we're using a "Substring Match", meaning that we're actually going to run this experiment on any page on this site on which
window.isProductPage page flag is set.
The nice part about using Optimizely as an AB testing tool is that you don't need to remove the flag from the page when you're done running a particular experiment. It's a relatively straightforward piece of code with zero side effects, and can be used for future experiments on the same group of pages!