Google Analytics Content Experiments: Regular expressions and backreference

394 Views Asked by At

I need to setup the experiment as follows:

Original: www.domain.com/original/x?param=something

Variation: www.domain.com/variation/x?param=something_else

Where x is variable and needs to be carried forward to the variation on the redirect.

Is Regular Expression and Backreferences supported by Content Experiment, so that I can do something like:

Original: www.domain.com/original/(.*)?param=something

Variation: www.domain.com/variation/$1?param=something_else

Is there a way I can setup the experiment URLs, the way that I need it to work?

3

There are 3 best solutions below

0
On

if your parameters have the same name, don't use the Regex for it. Just:

1) Replace("original","variation");
2) Replace("something","something_else");
0
On

@hwnd Thats sounds promising, however, I'm not sure what 'Search' and 'Replace' you were referring to.

I was referring to setting up Content Experiment as the title suggested.

Are you saying that I can set up the experiment as follows?

Original Page

Web page to experiment

www.domain.com/original/([\d+])?param=something

Variation 1

Web page to experiment

www.domain.com/variation/\1?param=somethingelse

Is this how I should set it?

0
On

I've tried the 2 options of backreferencing ( as suggested by @hwnd ) in the variation URLs:

  • \1
  • $A1

In both cases, the experiments managed to redirect to the variation URL however, both cases were unable to carry over the regex matched group value (x) to the variationi URL.

That means that in order to be able to do Google Experiment, we would have to change the URL format by moving x to the query string. :(