Optimize
2.1K members online now
2.1K members online now
Learn how to create your first experiment and get tips on creating A/B, redirect, and multivariate tests.
Guide Me
star_border
Reply

Experiment URL Regex Matching, Capture and Passing to Variants

[ Edited ]
Visitor ✭ ✭ ✭
# 1
Visitor ✭ ✭ ✭

Hi,

 

I'm trying to do experiments on our product pages and our URL patterns are like these:

Original:
https://www.example.com/p/[product-name]-[product-id]

ex: https://www.example.com/p/product-name-1

Variant 1:
https://www.example.com/q/[product-name]-[product-id]
ex: https://www.example.com/q/product-name-1

I managed to match my product URLs by using the pattern from this:

https://www.example.com/p/.*

 

But i need to capture the product-name-1 URL segment then pass it to the correct Variant 1 URL

 

So far i tried:

https://www.example.com/q/$1

https://www.example.com/q/${variable1}

 

But both are not working as intended.

 

My question is, how do one capture and pass URL segment to Variant URLs?