Matching multiple URLs and a query parameters in the same regex

Issue

When transferring query parameters on a Split URL experiment to the variations, you need to also match many different URLs added to the Site Area. 

To achieve that, you need a special regular expression to match all URLs bucketed in the Site Area and the query parameters as a group.

Solution

Insert the following regular expression in the Original URL section of your Variation menu on a Split URL Experiment:

(?:.*)((\?.*)*)

Then on the Variation URL you should place the following

http://domain.com/variationurl.html$1

The $1 will be replaced by the query parameters that will be matched.

So, for example, if the original URL is:

http://domain.com/sampleurl.html?hello=bye

The variation URL would result in:

http://domain.com/variationurl.html?hello=bye

Make sure that you test your expression with your expected URLs on the checker that is located on the Variation Editing menu, to verify it works correctly.

Important: When checking and unchecking the options in the Edit Split Url Variations area, (Support Regular Expressions and Transfer Original URL variables to the variation URL), be careful, as it will add a system-generated regex to the end of the Original URL, and can break any custom regex you may have added, like above.

 

Have more questions? Submit a request

Comments