If you are planning on running a Google Optimize test on a page that has subfolders (e.g. /product vs /product/myproduct) in a way that the experimentation targets only the root page, you can use a regular expression rule to target the root page specifically.
The reason for using a regular expression is that a traditional URL shift can cause the requests to sub folders to push the user back to the variant instead.
As illustrated in the above picture, by utilizing the regular expression \.*$ you are able to force the test to ignore everything beyond our target url /explore. There are probably many use cases for this Google Optimize URL regex hack that you can utilize for your A/B testing.
Bit of Background
Google Optimize is a great tool for running A/B testing on your website. I ran one such test for a client. That test was to do a split traffic share between an existing webapp as well as a new landing page that mimics its behavior. We were testing the results of such a test versus the traditional app.
We set up Optimize to run the split traffic test using a URL pageload event to split the traffic. This webapp had a lot of other features beyond what the landing page offered. So, we just split the traffic and thought it was going to be good.
Not true. What we learned setting it up the traditional URL shift way was that when you tried to link back to the main page, it would constantly push you back to the variant. Meaning, I could not use the extra functions of the webapp, like the search capabilities. So my B variant users were all stuck in an endless circle of trying to search for more stuff but never making it.
So how did I fix it?
After some intense Googling I found that nothing was really written with examples on how to do this kind of test.
But then I discovered that Google Optimize supports regular expressions on URL targeting (https://support.google.com/optimize/answer/6283424?hl=en#zippy=%2Cin-this-article) and by using our good friend Regex I was able to get it to ignore everything after the landing page (in this case the /explore) to target the landing page only.
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!