Regex (Regular Expression)

What is it?

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.

What is it used for?

In conversion rate optimisation, Regex is essentially used to define locations on your site where a project should be running or tracking conversions.

What are the benefits?

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.

What can you do with it?

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.

Examples of Regex in use

Let’s imagine you want to run a test on product pages only and have the following URL pattern for those pages:

www.examplewebsite/product/123456

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:

www.examplewebsite/product/.*

The “.*”will capture any text that comes after the “/product/” string, encompassing all product IDs and therefore all product pages.

Back to glossary

Back to top

More from the glossary

Product Recommendations

Product Recommendations can help your customers find what they're looking for.

READ MORE

Query String Attributes

What are Query String Attributes? How can you use them?

READ MORE

Reporting Dashboard

What is a Reporting Dashboard? Why use one? How is it different to a report?

READ MORE

Sales Funnel

What is the Sales Funnel (or eCommerce funnel)? What are the stages and how can you optimise it?

READ MORE

Get in touch

Want to know more about how Webtrends Optimize can help you with website optimisation? Click below to send us a message or call us on 0333 444 5502.

Send message