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.
Thanks for submitting your enquiry with us.
A member of the team will be in touch shortly to follow up with you.