Google Optimize will no longer be available after September 30, 2023. Your experiments and personalizations can continue to run until that date. Learn more

Create a redirect test

Test page variants that differ significantly from each other.
All web pages associated with a redirect test must include the Optimize snippet. Learn more.

A redirect test is a type of A/B test that allows you to test different web pages against each other. A redirect test contains different URLs for each variant. Redirect tests are useful when you want to test multiple different landing pages, or a complete redesign of a page.

Prerequisites

Complete the following steps before creating a redirect test:

  1. Create the alternate web page(s) you want to test and have the URL(s) ready.
  2. Install Optimize and Google Analytics on the page(s) you want to test.
  3. Link your Optimize container to your Analytics property. Note the following IDs:
    1. Optimize Container ID, e.g.: "OPT-123456" or "GTM-123456"
    2. Analytics Property ID, e.g.: "UA-123456-1"
  4. Install Optimize on all potential redirect destination page(s), using the property ID you linked to in Step #3.
  5. Check that your redirect destinations are on the same domain. Sub-domain redirects are supported, but cross-domain redirects aren't supported.

Definitions

Some of the key terms referenced in this article include:

  • Domain/path – Any part of a URL before the "?", or to the end of the URL if "?" is not present. For example, the highlighted part of the following URL:
https://www.example.com/product/laptop?id=123#price
  • Query string – The part of the URL from "?" to "#" (which can include one or more query parameters) or to the end of the URL, if "#" isn't present. For example, the highlighted part of the following URL contains a query string (?id=123&lang=en) that includes two query parameters (named "id" and "lang") with values assigned to the them.
https://www.example.com/product?id=123&lang=en#section2
  • Fragment – The part of a URL from "#" to the end. For example, the highlighted part of the following URL:
https://www.example.com/product?id=123&lang=en#section2

Types of URLs mentioned in this article:

  • Original URL (a.k.a. "original") – The URL of the page you want to test.
  • Redirect URL (a.k.a. "final") – The URL that results after Optimize applies its rules.
    • Note: query string and fragments from source URL (below) and specified by you in Optimize are merged.
  • Source URL – The visitor’s actual URL when visiting the site. This may differ from the original URL of a page because while the site visitor may land at this page, they are coming from a referral, web search, or ad all of whom may add query strings and fragments to the URL.

Learn more in the Optimize glossary.

Create your redirect experience

To create a new redirect test in Optimize:

  1. Navigate to your account page.
  2. Click on a container.
  3. Click Create experience.
  4. Enter a Name.
  5. Enter the URL of your editor page.
  6. Click Redirect test.
  7. Click Create.

Create a redirect test screenshot.

Add a variant

After creating your experience you'll land on the details page where you'll add your first variant:

  1. Under Targeting and variants
  2. Click Add variant.

Targeting and variants, Add variant (screenshot)

Choose a redirect test type

Optimize supports two types of redirect tests, single page and advanced.

  • Redirect to a single page – Redirect pages to a single web page (with one or more variants) by specifying a URL.
  • Advanced redirect – Modify part of the editor/original URL, redirect to multiple pages, and use regex.

Choose a redirect type, variant details (screenshot)

Start with a single-page redirect, which is the most common, then experiment with advanced redirects as your needs require.

Redirect to a single page

A redirect test is a great way to experiment with a web page redesign. Rather than launching it to all your visitors immediately, you can stage the new design at an alternate URL then use Optimize to test the design or roll it out incrementally. You can do this in Optimize by redirecting a portion of your website traffic to the alternate URL hosting your new design.

In this example, we redesigned our homepage and want to redirect 10 percent of visitors to the new page – which is hosted on a subdomain (new.example.com)to monitor conversions and feedback. After looking at the data, we can decide if the new design is meeting business objectives, and roll it out to 25%, 50%, 100% of visitors, as needed.

To create this redirect test in Optimize:

  1. Enter a Variant name.
  2. Enter a Redirect destination.
  3. Check the Final URL.
  4. Click Done.

Redirect to a single page (screenshot)

About redirect destinations

Query parameters and fragments in the editor page/original and redirect destination are merged to produce the final URL. Learn more in the definitions section above.

If a user arrives with conflicting parameters, the parameters entered when creating the Optimize experiment override any common parameters that the user arrives with. Learn more about parameter conflict below.

Advanced redirect

Advanced redirect tests allow you to modify parts of a URL by swapping, modifying, or adding strings to a single or multiple URLs. This provides granular control over constructing the final URL. In addition you can also enable the use of regular expressions (regex).

If you don't need this level of sophistication, start with a single-page redirect first.

To create an advanced redirect test, start by making an experience and variant (as outlined above), then click Redirect type > Advanced redirect.

Redirect type, advanced redirect selected.

The following fields are available in an advanced redirect test:

Field Behavior
Test type

Replace text – Default

Regex – see below

Find in domain/path (optional)

Searches the domain and path of the editor page/original URL for the entered value.

(blank by default)

Replace with

Entered value replaces what's found in the domain/path of the final redirect URL.

Leave blank to delete the value found in the domain/path field from the final redirect URL.

(blank by default)

Add/modify query parameters/fragments (optional)

Add/modify the query string as needed.
Entered values will be added to the site visitor’s actual URL and will replace common values already present in the URL.

Note: Only "add" and "modify" are available in the query string. Deleting query parameters or fragments isn't supported.

(blank by default)

Learn more about these and other testing terms in the definitions section (above) and in the Optimize Glossary of terms.

In advanced redirect mode, either the Find in domain/path or Add/modify... fields must contain a value. If you enter values in both fields, both conditions must be applied to a visitors URL for them to be redirected.

Note: If you enter values in both fields, visitors will only be redirected if Optimize can apply both values to the incoming URL.

Procedure

To create an advanced redirect test:

  1. Select Replace text (selected by default).
  2. Perform one of the following:
    1. Enter a value in the Find in domain/path field.
      1. Enter a value in the Replace with field (leave blank to delete the "find" value).
    2. Enter a value in the Add/modify query parameters/fragments field if desired.
  3. Click the redirect URL [New tab] and verify that it works as expected.
  4. Click Done.

Advanced redirect test options (screenshot)

Examples

Example 1: Redirect to a subdomain

For example, a large brand is launching a country-specific, ecommerce website for visitors from the United Kingdom. They want to redirect all UK visitors arriving to their homepage to a new website (hosted at a subdomain) with localized content, currency, and units of measure.

In this example we'll redirect visitors arriving at: https://www.example.com to: https://uk.example.com

This is a two-step process: 1) create an advanced redirect test, and 2) customize the audience targeting, as described below.

EX1:Step 1 – Create an advanced redirect test

Create an advanced redirect test with the following values:

Advanced redirect test type Replace text (default)
Find in domain/path www
Replace with uk
Add/modify query parameters/fragments (leave blank)
Original https://www.example.com/

Redirect

https://uk.example.com/

Here's how it looks in Optimize:

Advanced redirect screenshot

EX1:Step 2 – Customize the audience targeting

Next we'll use Optimize audience targeting so that only visitors from the UK are eligible to see your experience. After creating your experience in Step 1 above, you'll arrive back on the experience details page.

Under Audience targeting, click Customize:

Audience targeting, customize. Screenshot.

Under Choose rule type, click Geography:

Choose rule type: Geography

  1. Change the first drop-down menu to Country.
  2. Leave the second drop-down menu on equals.
  3. Type United Kingdom in the Values field.
  4. Click Add.

Audience targeting geography

Your completed audience targeting will look like this:

 audience targeting summary

Note: This could be set up with a single page redirect test by entering https://uk.example.com in its entirety. This example merely illustrates how to use an advanced redirect test to modify just a portion of the original URL.

Example 2: Modify paths across multiple incoming URLs

If you want to redirect multiple pages to multiple pages in an experiment, it can be done in two steps in Optimize:

  1. Set up redirect rules for each variant, and
  2. Customize your page targeting rules with "contains" or "starts with."

Once completed, any URL that matches your page targeting rules will be transformed according to the redirect rules that you set up.

In this example, we want to redirect visitors to any of our /product pages:

https://www.example.com/product/<category>/<product_id>

...to a new page design we're testing at a different path:

https://www.example.com/product-test/<category>/<product_id>

Just a sample of URLs that will be redirected in this example.

  • https://www.example.com/product/laptop/12345
  • https://subdomain.example.com/product/laptop/67890
  • https://www.example.com/product/desktop/12345
  • etc.

EX2:Step 1 – Set up redirect rules for the variant

Let's create a rule to search all source/incoming URLs for com/product, and replace it with com/product-test.

(Note: In this example we'll use the first URL, but any of the three can be used as the original.)

Advanced redirect type Replace text (selected by default)
Find in domain/path com/product
Replace with com/product-test
Add/modify query parameters/fragments (leave blank)
Original https://www.example.com/product/laptop/<product_id>

Redirect

https://www.example.com/product-test/laptop/<product_id>

Here's what it looks like in Optimize:

Variant details for an advanced redirect test.

EX2:Step 2 – Customize your page targeting rules

Modify the page targeting rules to ensure that we include any URL containing example.com/product, as follows:

Page targeting screenshot

This page targeting configuration ensures that all of the URLs specified above will be included in the experience, and that they will be redirected in the same manner:

From

  1. https://www.example.com/product/laptop/<product_id>
  2. https://beta.example.com/product/laptop/<product_id>
  3. https://www.example.com/product/desktop/<product_id>

To

  1. https://www.example.com/product-test/laptop/<product_id>
  2. https://beta.example.com/product-test/laptop/<product_id>
  3. https://www.example.com/product-test/desktop/<product_id>

Example 3: Add/modify parameters and fragments

Add or modify parameters and fragments to a visitor's incoming URL by creating an advanced redirect test with the following values:

Advanced redirect type Replace text (selected by default)
Find in domain/path (leave blank)
Replace with (leave blank)
Add/modify query parameters/fragments ?param1=newval1&param2=val2#fragment
Original http://.../product/?param0=val0&param1=val1

Redirect

http://.../product/?param1=newval1&param2=val2&param0=val0#fragment

 

Here's what that looks like in Optimize:
Advanced redirect test – Add query parameters and fragments

Example 4: Use regular expressions (regex)

Regular expressions (regex) are a notation for describing sets of character strings. Optimize supports regex (RE2 syntax) in the Find in domain/path and in the Replace with fields.

Note: Regex isn't supported in the Add/modify query parameters/fragments field.

Regex is available for advanced needs such as modifying the second occurrence of a string in a URL. This example replaces the second occurrence of "red" with "red-test," as follows.

Advanced redirect type Replace text (selected by default)
Find in domain/path (red.*?red)
Replace with $1-test
Add/modify query parameters/fragments (leave blank)
Original https://www.redexample.com/product/red/kitchen

Redirect

https://www.redexample.com/product/red-test/kitchen

 

Here's what that looks like in Optimize:

Use RegEx in an Optimize redirect test

Check that your redirect URL works as intended by clicking the new tab icon [New tab] , then click Done when complete.

Example 5: Modify paths across multiple URLs with regex

Regular expressions (regex) are a notation for describing sets of character strings. Optimize supports regex (RE2 syntax) in the Find in domain/path and in the Replace with fields.

Note: Regex isn't supported in the Add/modify query parameters/fragments field.

Regex is available for advanced needs such as manipulating multiple URL paths. Here we'll use regex to append a string (-test) to multiple category page URLs without having to list each of them manually.

Original URL Redirect URL
http://www.example.com/shoe http://www.example.com/shoe-test
http://www.example.com/apparel http://www.example.com/apparel-test
http://www.example.com/food http://www.example.com/food-test

This is how you can set this up in Optimize:

(Note: In this example we'll use the first original URL, but any of the others can also be used.)

Advanced redirect type Regex (select from drop-down menu)
Find in domain/path (com/[^/?#]+)
Replace with $1-test
Add/modify query parameters/fragments Replace text (selected by default)
Original https://www.redexample.com/product/red/kitchen

Redirect

https://www.redexample.com/product/red-test/kitchen

Check that your redirect URL works as intended by clicking the new tab icon [New tab] , then click Done when complete.

Targeting and objective

After creating your redirect test and entering the variant details there are only a few, but important, steps remaining to complete your experience setup. Next we'll guide you through the process of choosing an objective, the audience who should see the experience, and where to trigger your experience.

Configure targeting

Page targeting

This is the first of two criteria you specify that determine whether site visitors are eligible for an experience. Page targeting determines where (e.g. what page) Optimize should look for potential visitors to enter into the experience.

Continuing with the single page redirect example from above, as we only want to target a single page of the site, we would enter this original URL: https://www.example.com. Any visitor landing at this URL is considered for the experience if they also meet audience targeting conditions (the second trigger - outlined below).

Optimize targeting

Audience targeting

This is the second of two criteria you specify that site visitors must meet to be eligible for an experience. By default everyone landing on the page(s) outlined in page targeting is automatically eligible and no action on your part is required.

If you want to restrict the experience to a certain type e.g. audience, click Customize. Options include showing the experience only to visitors coming from a certain ad campaign or viewing the page on a mobile device. Once you make a selection click Save. You can add multiple audience criteria as needed.

If a site visitor satisfies both your page and audience targeting, they're eligible for the experience. Continuing the same example, this means they will be counted as entering the experience and randomly assigned to be shown either the original URL or the variant URL.

  • Original: https://www.example.com
  • Variant 1: https://new.example.com

Set an objective

An objective represents the primary criteria you want Optimize to use to determine if there is a clear leader. Configure your experiment objectives by scrolling down to the Objectives section:

  1. Click + Add experiment objective to choose a primary objective from amongst the list of options. Any goals set in Analytics will also appear here as an option for selection.
  2. Note only the primary objective above is used for determining a leader. Additional objectives can be added for the sole purpose of viewing in reporting

Edit variant weights

All variants are weighted equally by default in Optimize. A visitor who satisfies all targeting criteria and is included in your experiment has an equal chance of seeing any of your variants. If you want more (or less) traffic to go to a specific variant, you can adjust the weighting of visitors to target.

To edit the weights of your variants:

  1. Click on the percentage (%) listed next to a variant on the details page.
  2. Click Evenly split and select Custom percentages.
  3. Enter a value for each variant as a percentage (up to one decimal place).
  4. Click Done.

If you want equal weighting, click Evenly split again.

All of your variant weights must total 100%. If they don’t, you’ll see a red warning message. Simply adjust the weights so that they total 100%.

Check your rule

Check your rule

Optimize includes a convenient ability to enter any URL and verify whether the page targeting condition(s) above it will apply. Enter a full URL (copied from your browser’s location bar and includes the prefix http:// or https://) in the Enter URL field then click Check. If the condition you created above applies to the URL, you’ll see a green checkmark next to it. If the condition doesn't apply to the URL, you’ll see a red circle with a line through it.

To ensure that a condition applies to visitors of your regular website (http://) and your SSL website (https://) simply use the “or…” section of the condition builder to add both under page targeting. Then the condition will apply to visitors of both URLs.

Start your test!

Click Start experience back at the top, and congratulations, your experience is running live on the web! Most updates happen within one minute but depending on your configuration, allow up 15 minutes for it to deploy globally.

Next steps

How long should it run?

Keep an experiment running until at least one of these conditions has been met:

  1. Two weeks have passed, to account for the cyclical nature of web traffic during the week.
  2. At least one variant has a 95% probability to beat baseline.

Reports

To monitor a running experiment or see the results of a concluded experiment, click the Reporting tab at the top of the experiment detail page. The report is broken down into a series of cards that contain data about your experiment, including its status and how your variants perform against your objectives.

In addition to the reports included in Optimize, you can also see Optimize reports in Analytics. Sign in to Analytics, select the Reporting tab, then elect Behavior > Experiments in the report navigation.

Learn more about Optimize reports.

Define a canonical URL

If you frequently create redirect tests to experiment with multiple versions of a given page, we recommend that you define a canonical URL for your variants. This ensures that your redirect page variants won’t have an impact on your original page’s SEO rankings.

Indicate your preferred URL by adding a <LINK> element with the attribute rel="canonical" to the <HEAD> of your redirect variant pages. To learn more about canonical URLs, read Use canonical URLs in the Search Console help center.

Troubleshoot redirect tests

Chrome DevTools

If you aren't receiving experiment sessions after a page is redirected, you can use Chrome DevTools to determine if the page is redirecting properly:

  1. Open Chrome DevTools.
  2. Click on the Network tab.
  3. Check the box next to Preserve log.
  4. Enter the URL of the redirect experiment in the address bar and load it.
  5. If the page is not redirected, check your targeting rules.

Learn more about Chrome DevTools.

Resolve parameter conflict

Query parameters and fragments from the source URL and redirect destination are merged to produce the Final URL. If a user arrives with conflicting query parameters or fragments, those entered when creating the Optimize experience override those that a site visitor arrived with.

Example 1 – Parameter conflict

Query parameters in redirect destinations.

Page URL

http://www.example.com/original?s1=v1&s2=v2

Redirect destination

destination?s3=v3&s1=v3#dest

Final URL

http://www.example.com/destination?s3=v3&s1=v3&s2=v2#dest

Example 2 – Parameters in redirect destination don't conflict

If query parameters in the Source URL and Redirect destination don't conflict, the Final URL will contain both.

Source URL

http://example.com/home?s1=v1&s2=v2

Redirect destination

?d1=u1&d2=u2

Final URL

http://example.com/home?d1=u1&d2=u2&s1=v1&s2=v2&utm_expid=<expid>&utm_referrer=<referrer>

Example 3 – Parameters in redirect destination conflict

If query parameters in the Source URL and Redirect destination conflict, common query parameters in the Redirect destination override and appear in the Final URL.

Source URL

http://example.com/home?s1=v1&s2=v2&s3=v3

Redirect destination

?s2=u2&s3=u4&d4=u5

Final URL

http://example.com/home?s2=u2&s3=u4&d4=u5&s1=v1&utm_expid=<expid>&utm_referrer=<referrer>

Example 4 – Source fragment in redirect destination

A URL fragment, or fragment identifier, is the portion of a URL after a hash sign (e.g.: "#source").

If the Source URL includes a URL fragment, but the Redirect destination doesn’t, the Final URL will contain the fragment from the Source URL.

Source URL

http://www.example.com/path1#source

Redirect destination

/path2

Final URL

http://www.example.com/path2#source

Example 5 – Redirect fragment in redirect destination

If the Redirect destination includes a URL fragment, the Final URL will contain the fragment from the Redirect destination.

Source URL

http://www.example.com/path1

Redirect destination

/path2#target

Final URL

http://www.example.com/path2#target

Example 6 – Fragment conflict in redirect destination

If the Source URL and Redirect destination both include URL fragments, the fragment in the Redirect destination overrides the Source URL fragment and is included in the Final URL.

Source URL

http://www.example.com/path1#source

Redirect destination

/path2#target

Final URL

http://www.example.com/path2#target

Related content

Was this helpful?
How can we improve it?
Search
Clear search
Close search
Google apps
Main menu
false
Search Help Center
true
true
true
true
true
101337