Rich-text Reply

Split URL test at all product detail pages

KimWiebring 02-02-15

Split URL test at all product detail pages

Hi all,

 

Is it possible to use Regex in the 'Redirect Setup'? See:

http://awesomescreenshot.com/0e94bj7z32

 

I want to do a split URL test at all productdetail pages whereby people in the variation will be redirected to a productdetailpage with this addition to the URL :  /?bd=1

 

Thanks in advance!

 

Regards Kim

td_evans 02-02-15
 

Re: Split URL test at all product detail pages

[ Edited ]

Hey,

 

Just click okay - and then go to the edit code section.

 

Then pasted below this code:

 

/* _optimizely_redirect=http://custom */
$("head").append("<style>body{display:none;}</style>");
var url = window.location;
var queryString = url.search;
var prefix = queryString.indexOf('?') >=0 ? '&' : '?';   
var redirect_url = 'http://' + url.hostname + url.pathname + url.search + prefix + 'bd=1' ;
window.location = redirect_url;

 

 This code is what we use for our redirect tests, and works perfectly.

 

Thomas Evans
Technical Product Manager - Conversion @ Secret Escapes

Level 2
Brian_Abad 02-02-15
 

Re: Split URL test at all product detail pages

Great job, @td_evans !

 

Another set-up would be to utilize URL Targeting to determine a regular expression string of pages you would like this experiment to run. Then, we could utilize some custom redirect code (include this within the < edit code > box of your variation) to add a query parameter to the page:

 

/* _optimizely_redirect=http://custom */

//change this value to the query parameter you would like to include
var newparam = "test=true";
var _optly={redir:document.createElement("a")};
var loc = window.location.href.substr(0, window.location.href.indexOf("?") );
_optly.cur=window.location.search;
if(_optly.cur.indexOf(newparam) <= 0){
    loc += "?" + newparam;
    _optly.redir.href=loc;
    if (_optly.cur) {_optly.redir.search=_optly.redir.search ? _optly.cur + "&" + _optly.redir.search.slice(1) : _optly.cur;}
    window.location.replace(_optly.redir.href);
}

 

What happens is URL Targeting determines where an experiment will run. By targeting the regular expression string that encompasses the desired pages, we are effectively targeting the product pages where the redirect code will be ran. From there, the query parameter will be appended if the URL fits the indicated regular expression. 

 

The process would look like:

 

Does URL match URL Targeting --> Yes / No --> If yes, determine Traffic Allocation --> If in variation, run redirect code that adds query parameter

 

Let me know if any of this is unclear or if you have further questions!

---
Brian Abad
Manager, Technical Support
Customer Success
Optimizely
KimWiebring 02-04-15
 

Re: Split URL test at all product detail pages

Thanks @td_evans and @Brian_Abad for your quick reply! Smiley Happy

I hope it will work!
KimWiebring 02-04-15
 

Re: Split URL test at all product detail pages

Thanks for you help!

 

Visitors in de control version need to go to: http://www.fashionchick.nl/p/*/

Visitors in de variation need to go to: http://www.fashionchick.nl/p/*/?bd=1

 

I used  .*/p/*. in URL targeting, see:

http://awesomescreenshot.com/0154c2ceea

 

Is this correct? Or do I also need to add .*/?bd=1*.

 

Regards Kim

Brian_Abad 02-04-15
 

Re: Split URL test at all product detail pages

Hey @KimWiebring ,

 

This experiment will run for any URL that contains the regular expression match you've indicated. Please use the URL Match Validator (located within URL Targeting settings) to confirm the URL(s) that you are looking to encompass.

 

For the variation, the code I provided contains a variable called "newparam" -- set this value to "bd=1" since that is the query parameter you are looking to include. Here is the specific code that can be included within the < edit code > box of your variation.

 

/* _optimizely_redirect=http://custom */

//change this value to the query parameter you would like to include
var newparam = "bd=1";
var _optly={redir:document.createElement("a")};
var loc = window.location.href.substr(0, window.location.href.indexOf("?") );
_optly.cur=window.location.search;
if(_optly.cur.indexOf(newparam) <= 0){
    loc += "?" + newparam;
    _optly.redir.href=loc;
    if (_optly.cur) {_optly.redir.search=_optly.redir.search ? _optly.cur + "&" + _optly.redir.search.slice(1) : _optly.cur;}
    window.location.replace(_optly.redir.href);
}

 

What's happening is that once a user satisfies URL Targeting and if they are bucketed into the variation, this code is ran which will append the "bd=1" query parameter. The regular expression match will evaluate for the range of URLs that you would like to include the query parameter for.

 

Please let me know if any of this is unclear!

---
Brian Abad
Manager, Technical Support
Customer Success
Optimizely
KimWiebring 02-11-15
 

Re: Split URL test at all product detail pages

Hi Brian,

 

Thanks for the the specific code! Smiley Happy

 

The following screen appears after I have entered the code, and I can not aplly the code:

http://awesomescreenshot.com/0824dz5ja4

 

Am I doing somtehing wrong?

 

Thanks in advance!

 

Kim