Rich-text Reply

Creating a MVT test with a redirect

jshklt 10-30-14

Creating a MVT test with a redirect

I'm trying to create a multivariate test with one of the variations being a redirect since I'm having tons of trouble adding this specific element via the editor.


Optimizely is redirecting all variations, not just the one I set the redirect on. Is there any way around this? Here's an example of what I'm talking about:


Section 1: Headline




Section 2: Infographic


Variation - This is where the redirect should happen. It's essentially a clone of the original page so the headline test will work with the redirected page as well.


Instead, I'm seeing redirects for the other variations as well. Any advice would be appreciated. 

Level 2

Amanda 10-31-14

Re: Creating a MVT test with a redirect

Hey there. Is there a reason that you are using a redirect for the infographic as opposed to just swapping out the image? Also, are you seeing the redirect happen just in the editor, or are you seeing it happen in all variations live?

Using a redirect in a MVT test likely will not work because you will get stuck in an infinite redirect loop in both #2 and #4 below.

1. Headline Control - Info Control
2. Headline Control - Info Variation
3. Headline Variation - Info Control
4. Headline Variation - Info Variation

Best case scenario would be to include a new image as the Infographic variation instead of performing a redirect. Would this be possible?
JDahlinANF 10-31-14

Re: Creating a MVT test with a redirect

I never use the editor, so this may be a little too technical.


Suppose you have an A/B/C test where only the C group is redirected.

For ease of reading, let's presume the "B" group gets a "Blue Button" and the "C" group gets a "New Design"


Set up the test as a normal "one page" experiment.

URL Targeting should include the landing page.

"A-control" gets no code, because they see default content

"B-Blue Button" gets the code for the blue button

"C-New Design" gets some code to redirect the user to the new page.

The only piece of this code you need to modify is the value for "path to newPageGoesHere"

/* _optimizely_evaluate=force */
var _optly={redir:document.createElement("a")};
_optly.redir.href='//' + + '/path/to/newPageGoesHere' +;
/* _optimizely_evaluate=safe */


Note: if you have Analytics Integration set up, you will need to include the new landing page in your URL targeting.  This also means that users in the C group will be redirected to the page and then the code will execute again.  To stop the experiment from an infinite redirect scenario, we need to modify the code for the C group so that it does nothing on the new page.  We do this by adding the two lines in blue.  Note that you will need to still need to update the value for "/path/to/newPageGoesHere" in both places.


/* _optimizely_evaluate=force */
if (window.location.pathname.indexOf('/path/to/newPageGoesHere') == -1) {  var _optly={redir:document.createElement("a")};
  _optly.redir.href='//' + + '/path/to/newPageGoesHere' +;
/* _optimizely_evaluate=safe */


jshklt 10-31-14

Re: Creating a MVT test with a redirect

[ Edited ]

Hi Amanda,


I know how to set up MVT tests, but the way the landing page was set up (absolute positioning) makes it really hard to inject an image into it as it just lays overtop of the page instead of pushing everything below it in the DOM down.

I talked to Optimizely support yesterday and it sounds as if redirects and MVTs are mutually exclusive unfortunately. I should be able to hack something together in the editor or with jQuery but it'll be much uglier that I was hoping for.


Napoleon, that was the original solution I tried (within a MVT test) but the redirect wasn't just applying to the single variation. I may just end up setting up an A/B/C/D test next time and crunch the numbers myself.


Thanks to both of you for the replies!

Level 2