A Regular Expression (often shortened to Regex) refers to a string of text used to match a particular pattern. Regex is particularly useful for defining URL locations. The Regex string is coded according to a specific syntax, and the goal is to be able to cover more ground with a single line of text rather than having to write multiple lines.
In conversion rate optimisation, Regex is essentially used to define locations on your site where a project should be running or tracking conversions.
The most obvious benefit is a gain of time when defining the locations of your tests/conversions, particularly in a multiple-location scenario. But in some cases where a URL dynamically updates according to data input on the page by a user (for instance, an airlines’ search results page may contain dynamic details about the chosen origin/destination airports, the outbound/inbounds dates, etc.), Regex will be a life saver as you could not otherwise cover all the potential combinations that can appear in the URL.
With Regex, you can refine matching down to the exact character/word/string you need, or go broad and catch much wider expressions. All you need to do is learn the basic syntax, which can easily be done with free online tutorials.
Let’s imagine you want to run a test on product pages only and have the following URL pattern for those pages:
In this instance, the integer element refers to a potential product ID and will change for every single product page.
If you want your AB test to run on all product pages, there’s no need to list every single product ID manually. You can capture all product pages and their product IDs in one go with the following Regex:
The “.*”will capture any text that comes after the “/product/” string, encompassing all product IDs and therefore all product pages.
Product Recommendations can help your customers find what they're looking for.READ MORE
What are Query String Attributes? How can you use them?READ MORE
What is a Reporting Dashboard? Why use one? How is it different to a report?READ MORE
What is the Sales Funnel (or eCommerce funnel)? What are the stages and how can you optimise it?READ MORE