Dev GuideAPI Reference
Dev GuideAPI ReferenceUser GuideProduct feedbackGitHubNuGetDev CommunitySubmit a ticketLog In

Integrate Google Analytics Classic

Use Google Analytics Classic to read data from Optimizely Web Experimentation, track GA metrics as experiment goals, and create custom variables and reports in Google Analytics to track and report on Optimizely data.

Integrate Optimizely Web Experimentation and Google Analytics Class to have a direct view of how Optimizely Web Experimentation experiments affect the metrics you track in Google Analytics. Once integrated, you can see Google Analytics data for each variation in your experiment. You can also filter your Google Analytics reporting by visitors who were successfully included in an Optimizely experiment and exclude those who were not. If you are running redirect experiments and intend to view your data in GA, you need to turn on this integration for your traffic source information to report correctly. Otherwise, Optimizely Web Experimentation will not be able to set a necessary variable, and your traffic will report as "Direct."

📘

Note

If you experience issues with this integration or if you see discrepancies in your reports, see our GA troubleshooting article for more information.

Prerequisites

Optimizely currently supports only the latest version of the GA tracking code, which looks like the following:

  • Note the use of gaq instead of the older gat object to make the tracking call. Only pages that use _gaq are currently supported. You can retrive the latest tracking code from Google Analytics by going to Admin > Tracking Info > Tracking Code.
  • You must place the GA tracking code at the bottom of the  section of your pages. Google Analytics integration will not function properly unless the Optimizely Web Experimentation Snippet is above the GA snippet.
  • Optimizely Web Experimentation makes use of custom variables for the Google Analytics Integration, which are limited to 5 slots per tracking call. Select a slot number for each experiment that is not in use by another experiment or by other tracking activities.
  • Make sure that your Optimizely Web Experimentation experiment is running for this integration to work.

📘

Note

Integration with Google Analytics is not required in order for Optimizely Web Experimentation's analytics to work. If there is no integration between the two platforms, you will still see the indirect effects of Optimizely Web Experimentation experiments (for example, increased conversion rate of a variation) within Google Analytics.

Turn on the integration

  1. Go to Settings > Integrations.
  2. Select Google Analytic (Classic) and toggle the integration to On .

📘

Note

To enable Google Analytics Classic for an individual experiment, go to that experiment in the editor, then click Options > Integrations.

Enable the integration on your experiment

Enable Google Analytics Classic for each experiment from the editor:

Multiple Google Analytics trackers

If your page contains multiple trackers on the page for use with multiple Google Analytics accounts, you can integrate with just one of those trackers. By default, Optimizely Web Experimentation will use the default tracker, but you can choose another tracker instead by entering it in the Specify Custom Tracker field.

In the following example, account UA-65432-1 will receive Optimizely experiment data because it is tracked by the default tracker. Account UA-65432-2 will NOT receive experiment data because it is tracked by the tracker "t2".

📘

Note

For more information on using multiple Google Analytics accounts at the same time, see Google's documentation:

Tracking Code: The _gaq Global Object
Introduction to ga.js (Legacy)

View your data

  1. Click the Reporting tab, and then click the down arrow in the top-left corner of the frame.
  1. Click Create New Segment and then, under the Advanced tab, click Conditions to begin setting your custom Optimizely Web variable.
  1. You will now be setting the Key for your Optimizely experiment. Click the dropdown to add a metric and choose Custom Variable (Key X), where X is the custom variable slot that you have chosen for your Optimizely test. For instance, if you chose custom variable slot 1, you will choose Custom Variable (Key 1) from the dropdown.
  1. Start typing the word Optimizely and you should see a list of valid experiments populate. Select the appropriate experiment (note that it may take up to 24 hours after installing the snippets and enabling the integration for GA to start seeing data and this auto-populate to start).
  1. You will now be setting the Value that corresponds to the Key. To do this, add another metric using the And condition.

Select Custom Variable (Value X) where X corresponds to the X from the experiment metric. Again, for instance, if you chose value 01 in your experiment, then select Custom Variable (Value 01).

  1. Type in the name of the variation. You can also click the blank text box to see the variations available to you. You should only select one variation at this time. For example, in the below image, you may choose to select Original to track for this value.
  1. This allows you to view all of your data by this custom metric. So, when you click save you will see a new advanced segment. Do this as many times as needed to add each variation in your experiment. So, again using the above example, if you selected Original the first time you created a variable, you will now repeat the process by setting a new variable with the value Variation_1 and if you had another variation, you would create another variable for Variation_2 and so on.
  2. Now, to see your custom variables, go to Audience > Custom > Custom Variables. This will show you the various custom variables that you have set up.
  1. Click the custom variables associated with your Optimizely experiment, then click Apply at the bottom.
  1. Experiment titles will appear as "Optimizely_[experiment title]" and truncated to 28 characters. Variation titles will be truncated to the first 24 characters. Experiment and variation titles that contain non-Latin characters may not be reported correctly in Google Analytics. For multivariate experiments, up to 4 variation titles will each be truncated, and then joined with a tilde (~), such as "blue~green~purple~red".
  2. When custom segments are selected, your data is split up by the Optimizely Experiment/Variation combination that is relevant.

Check your integration

GA’s Custom Variables contain visitor-specific information that can be sent along with events and pageviews. It can take up to 24 hours to populate that data into GA; however, the Custom Variable is set immediately once you integrate GA and Optimizely, so you can check that the Custom Variable is set correctly using Google Analytics’ debugger tool.

Using the debugger tool, look for the variable customVar [x] where ‘x’ is the slot corresponding to the Optimizely experiment. The variable will be set with the Optimizely experiment followed by the variation you were bucketed into.

An example would look like this:

Custom Var 1: label:'Optimizely_HomePage (1645002506)' value: Variant#1' scope:'2'