Rich-text Reply

Redirection to a URL where experiments run

neerajtiwari 10-23-16

Redirection to a URL where experiments run

Hi, I wanted to redirect a same url in which the experiment is running with added parameter, say http://www.xyz.com and I need to redirect to http://www.xyz.com/?test=newUrl&abc=newParameter, how to achive this.

 

Thanks in advance.

Mateus 10-24-16
 

Re: Redirection to a URL where experiments run

[ Edited ]

 

/* _optimizely_redirect=http://custom */
$("head").append("<style>body{display:none!important;}</style>"); //This is to stop flash of unstyled content
var url = window.location;
var queryString = url.search;
var prefix = queryString.indexOf('?') >=0 ? '&' : '?';
var redirect_url = location.protocol + '//' + url.hostname + url.pathname + url.search + prefix + 'utm_content=different_layout' ;
window.location = redirect_url;


I got the answer from another thread. I always use this code. One thing I usually add so the redirect doesn't loop is to exclude the parameter substring in the Target URL. So in your case, abc=newParameter should be excluded from the target URL.

https://community.optimizely.com/t5/Using-Optimizely/URL-Redirection-on-multiple-pages/td-p/10526

 

❤️ Optimizing
Level 2