This article will help you:
  • Test two homepages against one another
  • Set up redirect experiments (split URL tests) in Optimizely, which redirect visitors from one URL to another
  • Ensure that you can track goals on both your original and redirect pages
  • Understand why your redirect variation might be reporting 0 conversions on the results page
  • Create an experiment that modifies the URL, or other advanced redirects

Redirect experiments at a glance

Redirect experiments, or split tests, allow you to compare two separate URLs as variations in an A/B test. For example, you might create a redirect experiment that compares two versions of a landing page.

Key tips

What to watch out for

  • Make sure your URL targeting doesn't capture both original and redirect URLs
  • The Optimizely snippet must be on the original and the redirected page
  • Don't remove the/* _optimizely_redirect=http:// */portion from code samples

Do you have two landing pages to compare? Or two separate versions of a page? You can create "split URL" experiments that simply redirect a visitor to a different URL as a different variation. This means you can use Optimizely to easily test whole pages against each other.

Want to see how to setup a redirect experiment and follow along? Watch our two-minute video on setting up a redirect test.

 
Tip:

Have a question about setting up your experiment? Head over to the Optimizely Community to post a discussion and see what others are talking about.

Redirect experiments function a little differently from other Optimizely A/B experiments. When you create a redirect experiment, use this checklist to make sure that you've set it up correctly. Each section in this article will help you set up your redirect experiment per this checklist:

Check for: Section:
Basic setup: select Redirect to a new page from the Variation menu Setup
URL Targeting infinite loops: make sure your URL Targeting doesn't capture both the original and redirect URLs Setup: URL Targeting
Goals: Set up Goal Targeting if you're tracking a click goal on the redirect page Tracking Clicks (Goal Targeting)
URL Modifications: Customize the experiment if you want to modify the URL upon redirect Advanced

Set up a redirect variation

To create a variation that redirects a visitor to another page,  just follow these instructions:

 
Tip:

In order to improve SEO link and ranking signals, the redirected page must indicate that the original page is the preferred (canonical) destination.  To do this, add a <link> element with the rel="canonical" attribute into the <head> section of the redirected page. Check out this Google Support Doc for more information.

  1. Create a new experiment and choose one of the pages that you want to test as the URL. This will be your "original" variation.


     
  2. Click the Variation menu and select Redirect to a new page...


     
  3. Now, enter the URL of the other page that you'd like to test in this experiment. Based on your traffic allocation, visitors will now be directed to either of the URLs that you've entered.

     
    Note:

    When you load a redirect page, you won't be able to edit it in the Editor. You'll see a prompt that prevents you from editing the page. If you need to track clicks on your redirect page, see the section on goal targeting in our click tracking article.

  4. When setting URL Targeting, don't target the redirect page or use a substring match that targets both the original and redirect pages! If you do either of these, you'll cause an infinite loop of redirects that causes your experiment not to activate. For example, if you're running a redirect test between myfakesite.com/lp1 and myfakesite.com/lp2 then don't substring match myfakesite.com. Most often, you'll want to use a simple match on your original page's URL.
     
  5. Redirecting with query parameters: If you have URLs with dynamic parameters that you want to keep when you redirect to the new page, click the option to Redirect with live query parameters included. For instance, if a visitor lands on example.com/original-page/?test=true and gets redirected into the variation, they would be redirected to example.com/redirect-page/?test=true. If this setting wasn't checked, the visitor would be redirected to example.com/redirect-page without any additional query parameters.
     
  6. Want to track a goal on your original and redirect page? Keep reading -- we walk through this process in the "tracking clicks on a redirect page" section below.
 
Important:

Make sure you have your Optimizely snippet on both the original page and the page to which you are redirecting in your variation. If it's not on the new page, your visitors may not all be tracked.

Experiments that redirect to a different domain may experience tracking issues for those redirected visitors. Please refer to our other knowledge base article that details this topic and explains further.

Goal targeting: Track clicks on a redirect page

If you are looking to compare clicks on elements between a page and the redirected page, you'll need to use goal targeting to make sure that Optimizely will track clicks on both your original and redirect page.

 
Important:

If you start your experiment and notice that your redirect variation is not recording any conversions, you most likely have set up goal targeting incorrectly (or not set it up at all). Read the following section to find out more on how to set up goal targeting.

  1. Go to your original page in the Editor. Click the Goals icon () in the top right of the Editor.
     
  2. Click Create a New Goal.


     
  3. In the goal tracking dialog, choose Click Goals from the drop-down menu and name the goal.


     
  4. Now you'll choose the element that you want to track clicks on. Click  to see your full page if you need more space to find it.
     
  5. Select the element you wish to track on your original page; you will see the element highlighted in red. A red border will appear around it.


     
  6. Now, you'll find the element in your redirect page. Here's how: Look for the URL used for preview below field and change it to the URL of your redirect page. Now hit Enter/Return to see the page.


     
  7. Select the element you wish to track on your redirect page; you will see the element highlighted in red. If the item is already highlighted in red, you shouldn't take any additional action.
     
  8. Click  if you had expanded the page.
     
  9. Click the Advanced link at the bottom of the window, to open the Advanced tray.


     
  10. Under Goal Targeting, select Specify custom pages on which to track this goal, and enter the URLs of your original and redirect pages. Use the + button to add more URLs.

     
    Note:

    If you're curious about what's going on in these steps, here's what you're doing: by default, all click goals will only be tracked on pages that meet the experiment’s targeting conditions. When you wish to track a click goal on a page that exists outside of the targeting conditions you must manually specify these pages.

  11. You can use the same match type conditions as in URL Targeting, i.e simple match, substring match, exact match. But for a redirect experiment, you will typically want to use Simple Match on the original page URL and redirect page URL.
     
  12. Click Save. Now your goals will track for both your original and redirect pages!
 
Important:

Before creating goals for your experiment, please ensure the Optimizely snippet has been added to any page on which you wish to track goals.

Unblock other redirects

By default, when you set a redirect, Optimizely blocks other redirects for 5 seconds so that you will not cause an infinite loop of redirects.

For example, this might happen if you set a redirect test from www.example.com/original to www.example.com/redirect and you have set URL targeting to a substring match for www.example.com. 

Because both the original and redirect page meet the targeting conditions, you will trigger an infinite redirect loop.

If you do not wish to have this 5 second check, and you are absolutely sure that your URL targeting does not include any matches for the site being redirected, then you can turn this off with the Edit Code function by changing the value '_optimizely_redirect' to '_optimizely_redirect_no_cookie'

Advanced redirects

In our developer docs, we outline several advanced use cases for redirect experiments that involve adding custom code to the Edit Code box, such as:

 
Important:

When you use the code samples, make sure to keep the /* _optimizely_redirect=http:// */ portion of the code. This is necessary to tell Optimizely that this is a redirect variation. You can replace the "custom" portion with an alternate string of your choice (it displays in the pop-up in the Editor) but the http(s)-protocol IS important.

  1. Load the page you want to use as the original page. If you want to modify multiple pages just select one at random and load that into the editor.
     
  2. Click the Variation menu > Redirect to a new page... When the dialog comes up, leave the example URL in there, and uncheck the Redirect with live query parameters included checkbox.


     
  3. Click the Edit Code box at the bottom of the page, and enter the code from the developer docs, replacing the dummy text where necessary.   
 
Note:

Keep in mind that if you are adding a new URL parameter, it will append to the currently loaded URL. If the currently loaded URL already has a URL parameter, you will need to use '&'. If it does not, you will need to use '?'. 

When you do a preview in Optimizely, we use our own URL parameters, so be aware that when the experiment is running live, those parameters won't be there.