Google Optimize Regular Expression Rule to Ignore URL Subfolders

Sean Gowing
Sean Gowing
|
April 7, 2022
Google Optimize Regular Expression Rule to Ignore URL Subfolders

(updated 03/2023)

Intro:

Suppose you intend to run a Google Optimize test on a webpage containing subfolders such as /product and /product/myproduct. In that case, you can use a regular expression rule to target the root page exclusively without affecting subfolders. By applying the .*$ regular expression, you can prevent the test from considering anything beyond the target URL /explore, as shown in the image above. This Google Optimize URL regex hack can be used for various A/B testing purposes.

Learn more about regex here or here

What is Google Optimize?

Google Optimize is an excellent tool for performing A/B testing on your website. For a client, I ran a split traffic test between an existing web app and a new landing page that replicated its behavior. We used Optimize to conduct the split traffic test by splitting traffic using a URL pageload event. However, the web app had numerous features that the landing page didn't offer, such as search capabilities. When we attempted to link back to the main page, it kept pushing us back to the variant, making it impossible to use the extra functions of the web app. Therefore, users of variant B were stuck in an endless cycle of searching for more stuff but never finding it.

The Cure!

After extensive research, I discovered that Google Optimize supports regular expressions (regex) on URL targeting, which can be used to ignore everything beyond the landing page (in this case, /explore) to target the landing page only. By utilizing the regex, we were able to prevent the test from pushing users back to the variant and avoid the issue of limited search capabilities.

*https://support.google.com/optimize/answer/6283424?hl=en#zippy=%2Cin-this-article

Written By
Sean Gowing
CEO of SocialCatnip
Need help?

Contact Us

Reach out to us today. We are always working to improve our services so you can stay on top of your digital marketing goals. Simply fill out our online form to get jump-start your digital marketing today!

Contact submission will be responded to within 24 hours. Thank you for reaching out to us.

Fields marked with an asterisk (*) are required.

Thank you! Your submission has been received!
Oops! Something went wrong while submitting the form.