Skip to main content
menu_icon.png

Everything you need to switch from Optimizely Classic to X in one place: See the Optimizely X Web Transition Guide.

x
Optimizely Knowledge Base

Enhanced Redirect Analytics

Relevant products:
  • Optimizely X Web Experimentation
  • Optimizely X Web Personalization

This article WILL HELP YOU:
  • Run redirect experiments across origins
  • Track events and visitors of a redirect experiment in third party analytics

How it works

In response to a previous issue, we updated how Optimizely X tracks data across origins for redirect experiments. When performing a redirect, the snippet can now store information about the campaign decision in a cookie, allowing the snippet on the post-redirect page to track the decision to various analytics backends.

Note: We are in the process of rolling this out to all customers. If you are using the new enhanced redirect analytics, you'll see the following dialog when using the redirect feature. If your account hasn't been added yet, you'll continue to see the "Redirect Analytics Under Maintenance" dialog. You can contact your account manager to request expedited access.

What's supported

  • Types of redirects:

    • one origin to another within a single cookie domain (same as in Classic)

    • one snippet to another, even between unlinked projects, as long as the two snippets are in the same account.

  • Analytics tracking:

    • Optimizely results (including with X Events API enabled)

    • Mixpanel

    • Adobe

    • Google Analytics Universal

    • Google Analytics Classic

    • custom analytics integrations

What's not yet supported

  • Types of redirects:

    • one cookie domain to another (also unsupported in Classic; may eventually be supported in X)

  • Analytics tracking:

    • Clicktale (you may not see any visitors in the redirect variation, as you would if you had not opted into the new redirect system)

Third Party Analytics and redirecting to a page with a different snippet

We don't include code for all possible integrations in every snippet. That would be a waste of bandwidth and slow your page load time. Instead, we add integration code to the snippet when you enable an integration for a project or experiment.

If you are using a third party analytics integration and redirecting to a page with a different Optimizely snippet in your account, the post-redirect snippet needs to have the analytics integrations enabled separately. This means if you intend to track the redirect experiment using a tool like Google Analytics, the snippet on the page you are redirecting to needs to also have the Google Analytics integration enabled. Since integrations are typically enabled on a per-experiment basis, this could mean the post-redirect snippet doesn't know about the redirect experiment and it's integration settings.

To work around this constraint, you could do one of the following:

  • Enable the integration for all experiments in the project where the post-redirect snippet lives (option not available for all integrations)

  • If there is already an experiment running in that snippet that is using the integration you should be ok. There might be some issues relying on this method (e.g. the person pauses the test before yours completes).

  • Create an A/A test for that post-redirect page's snippet where you use the Google Analytics integration.

Debugging the redirect cookie

Append ?optimizely_log=debug to your URL and open the developer console in your browser. Search the log for a line containing Optly / Relay / Found redirect cookie. That line will contain the cookie information. The cookie is set on pre-redirect page and the Optimizely log is reading and printing it from the post-redirect page.

If you parse the cookie information by "&" you can review the data passed from the pre-redirect page to the post-redirect page.

Relayed field name Purpose More info
a Account ID  
aId Activation ID  
as Audience IDs  
cV X Web client version  
d Decision ID  
i Visitor ID  
isv Integration string version Indicates the analytics naming convention
l Campaign ID  
lN Campaign Name Unavailable if masking descriptive names
lP Campaign Policy  
n Snippet Revision  
ns localStorage Key Namespace  
p Project ID  
r Referrer Empty string if the referrer couldn't be determined on the pre-redirect page
s Session ID  
t Time since Unix epoch Use a converter if you want a more readable timestamp
v Variation ID  
vN Variation Name Unavailable if masking descriptive names
x Experiment ID  
xN Experiment Name Unavailable if masking descriptive names

What to watch out for

  • The new redirect system doesn't change Optimizely's tracking requests or attribution model, but it does change how analytics are implemented throughout the X Web client. Thus it could introduce results discrepancies, even for non-redirecting campaigns and experiments.

    • Confirm that the new redirect experiment has a roughly equal number of visitors in the redirect and non-redirect variations (there may be some visitor loss in the redirect variation, but it shouldn't be too high). Confirm that the conversion numbers also make sense.

    • Confirm that there aren't any suspicious discontinuities (sudden increase or decrease) in visitor counts or conversion counts in the timeseries for other active experiments that are included in the same snippet.

  • An opted-in snippet will set a large (but temporary) cookie for the duration of the redirect. Specifically, it will set an optimizelyRedirectData cookie that can contain ~500 characters, or even more if there was a long referrer URL to the pre-redirect page. This could cause the customer's server to return an error instead of the expected post-redirect page (but only for redirected visitors, and only in the immediate aftermath of a redirect; pausing the redirect experience will restore functionality).

    • We recommend that you QA the redirect experience on the customer's servers before unlocking it for live visitors.

    • Cookie size will decrease in the distant future. See Phase 3 of the redirects launch plan.

If you encounter any issues, ping @nikhil in the #analytics-redirects Slack channel, and feel free to follow the opt-out instructions at the bottom of this page.

Steps for opting in

In order to execute a redirect with the new analytics system, the snippet that executes the redirect must be explicitly opted in, or part of the full stack experiment rolling out the fix. This requirement will be eliminated in the future, once it's fully rolled out.

Please inform @byron in the #analytics-redirects Slack channel, or directly modify the beta spreadsheet, to ensure that ADEPT has good sense of how the rollout is going. Then follow these instructions to perform the opt-in:

For all snippets in an account

Enable REDIRECTS_V2 feature in Account Details on success board.

Note that you still may need to modify certain "redirect destination" snippets according to Additional steps if you're redirecting to a page with a different snippet, if the destination snippet doesn't include any Experiments using the desired third-party integration.

For a Custom Snippet

Emulate the account, open your browser's developer console, and enter

(function(snippetName) {
  $.ajax('/api/v1/snippets').then(function (data) {
    var snippet = _.find(data, {
      resource_id: snippetName,
    });
    var newOverriddenDefines = _.extend({}, snippet.client_build_settings.overridden_defines, {
      "__DEFAULT_REDIRECT_RELAY_MEDIUM__": "\"COOKIE\"",
      "__REDIRECT_RELAY_MEDIA__": {
        "COOKIE": true,
      },
    });
    return $.ajax('/api/v1/snippets/' + snippet.id, {
      type: 'put',
      contentType: 'application/json',
      data: JSON.stringify({
        "client_build_settings": {
          "overridden_defines": newOverriddenDefines
        }
      }),
      headers: {
        'x-csrf-token': optlyConfig.csrf
      }
    });
  }).then(function () {
    console.log('Enabled new cookie redirects in snippet:', snippetName);
  }, function (e) {
    console.log('Error enabling new cookie redirects in snippet:', snippetName, e);
  });
})('SNIPPET_NAME');

after replacing SNIPPET_NAME with the actual name of the snippet in question.

For a basic, project-specific snippet

Emulate the project, go to Settings > Implementation > Optimizely X, and ensure that the Overridden Defines section includes the following (omit the "..." and trailing comma(s) if there is no content there; those are there to indicate that there may be other content above/below this):

{
  ...
  "__DEFAULT_REDIRECT_RELAY_MEDIUM__": "\"COOKIE\"",
  "__REDIRECT_RELAY_MEDIA__": {
      "COOKIE": true
  },
  ...
}

If the project has no other Overridden Defines, remember to remove the trailing comma. The UI will warn you if you forget.

Resave

Go to the post-redirect page, open the developer console, and enter

window.optimizely.get('data').clientVersion

Confirm that the version is at least 0.56.0. If not, the snippet probably hasn't been modified since May 15, 2017. You just need to resave it using Labs > Resave.

Third-party analytics

If you're expecting results via one of the supported third-party analytics integrations, you need to make sure the integration is included in the post-redirect snippet even though that the integration may not be explicitly enabled for any campaign or experiment in that snippet.

For a redirect to a basic, project-specific snippet

You likely don't need to do anything here because you're original page and redirect page are on the same snippet and would include the 3rd party analytics tracker in the snippet if you enabled it for the experiment.

If you're redirecting to a separate snippet and want to ensure the 3rd party plugin is included in the snippet, you can follow these steps to add it.

Emulate the post-redirect project, go to Settings > Implementation > Optimizely X, and ensure that the Overridden Defines section includes the following if enabling Adobe Analytics:

{
  ...
  "__ANALYTICS__": {
    "ADOBE": true
  },
  ...
}

or the following if enabling Mixpanel:

{
  ...
  "__ANALYTICS__": {
      "MIXPANEL": true
  },
  ...
}

or both:

{
  ...
  "__ANALYTICS__": {
    "ADOBE": true,
    "MIXPANEL": true
  },
  ...
}

Each integration that you specify may increase the size of the snippet payload, so only include integrations that the customer is likely to use in their pre-redirect snippets.

If the project has no other Overridden Defines, remember to remove the trailing comma. The UI will warn you if you forget.

For a redirect to a Custom Snippet

Emulate the account, open your browser's developer console, and enter

(function(snippetName) {
  $.ajax('/api/v1/snippets').then(function (data) {
    var snippet = _.find(data, {
      resource_id: snippetName,
    });
    var newOverriddenDefines = _.extend({}, snippet.client_build_settings.overridden_defines, {
      "__ANALYTICS__": {
        // Only include if necessary
        "ADOBE": true,
        // Only include if necessary
        "MIXPANEL": true,
      },
    });
    return $.ajax('/api/v1/snippets/' + snippet.id, {
      type: 'put',
      contentType: 'application/json',
      data: JSON.stringify({
        "client_build_settings": {
          "overridden_defines": newOverriddenDefines
        }
      }),
      headers: {
        'x-csrf-token': optlyConfig.csrf
      }
    });
  }).then(function () {
    console.log('Enabled new cookie redirects in snippet:', snippetName);
  }, function (e) {
    console.log('Error enabling new cookie redirects in snippet:', snippetName, e);
  });
})('SNIPPET_NAME');

after replacing SNIPPET_NAME with the actual name of the post-redirect snippet and after filtering the list of integrations (ADOBE, MIXPANEL , etc.) as necessary. Each integration that you specify may increase the size of the snippet payload, so only include integrations that the customer is likely to use in their pre-redirect snippets.

Steps for opting out

You revert the opt-in process if necessary.

For all snippets in an account

Remove the REDIRECTS_V2 feature from the Account using success board.

For a Custom Snippet

Emulate the account, open your browser's developer console, and enter

(function(snippetName) {
  $.ajax('/api/v1/snippets').then(function (data) {
    var snippet = _.find(data, {
      resource_id: snippetName,
    });
    var newOverriddenDefines = _.extend({}, snippet.client_build_settings.overridden_defines, {
      "__DEFAULT_REDIRECT_RELAY_MEDIUM__": undefined,
      "__REDIRECT_RELAY_MEDIA__": undefined,
    });
    return $.ajax('/api/v1/snippets/' + snippet.id, {
      type: 'put',
      contentType: 'application/json',
      data: JSON.stringify({
        "client_build_settings": {
          "overridden_defines": newOverriddenDefines
        }
      }),
      headers: {
        'x-csrf-token': optlyConfig.csrf
      }
    });
  }).then(function () {
    console.log('Enabled new cookie redirects in snippet:', snippetName);
  }, function (e) {
    console.log('Error enabling new cookie redirects in snippet:', snippetName, e);
  });
})(SNIPPET_NAME);

after replacing SNIPPET_NAME with the actual name of the snippet in question.

For a basic, project-specific snippet

Emulate the project, go to Settings > Implementation > Optimizely X, and remove the __DEFAULT_REDIRECT_RELAY_MEDIUM__ and __REDIRECT_RELAY_MEDIA__ from the Overridden Defines section.