- Integrate Google Analytics Classic to read data from Optimizely
- Track GA metrics as experiment goals
- Create custom variables and reports in Google Analytics to track and report on Optimizely data
If you use Google Analytics (GA) to monitor your site's traffic, you can view the results of your Optimizely experiments alongside the rest of the data that GA collects. In this article, we'll walk through how to implement Google Analytics.
Why integrate Optimizely and Google Analytics?
- You'll have a direct view of how Optimizely experiments affect the metrics you track in Google Analytics.
- You'll be able to see Google Analytics data for each variation in your experiment.
- You'll be able to filter your Google Analytics reporting by visitors who were successfully included in an Optimizely experiment and exclude those who weren't.
- If you're running redirect experiments and plan to view your data in GA, you'll need to turn on this integration for your traffic source information to report correctly. Otherwise, Optimizely won't be able to set a necessary variable, and your traffic will report as "Direct."
Are you looking for a different Google Analytics Integration? If so, check out our article on implementing Google Universal Analytics.
Are you troubleshooting your Google Analytics integration, or see discrepancies in your reports? See our GA troubleshooting article for more information.
Implementing Optimizely and Google Analytics in a tag manager? Read our article on tag managers to find out more about how this will affect your GA tracking code.
Navigate to Settings > Integrations. Select Google Analytic (Classic) and toggle the button to ON in the Integration Details sidebar on the right side of the page.
To enable Google Analytics for an individual experiment, go to that experiment in the Editor, then click Options > Integrations.
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. The latest tracking code can be obtained from Google Analytics by navigating to the Admin tab, then click Tracking Info > Tracking Code.
- The GA tracking code must be placed at the bottom of the
<head>section of your pages. Google Analytics integration will not function properly unless the Optimizely Snippet is above the GA snippet.
- Optimizely makes use of Custom Variables for 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 experiment is running for this integration to work.
Integration with Google Analytics is not required in order for Optimizely’s analytics to work. If there is no integration between the two platforms, you will still see the indirect effects of Optimizely experiments (e.g. increased conversion rate of a variation) within Google Analytics.
Enable Google Analytics Integration
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 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".
For more information on using multiple Google Analytics accounts at the same time, please visit the following pages:
- Click the Reporting tab, and then click the down arrow in the top-left corner of the frame.
- Click Create New Segment and then, under the Advanced tab, click Conditions to begin setting your custom Optimizely variable.
- 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.
- 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).
- 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).
- 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.
- What this will let you do is 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.
- 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.
- Click the custom variables associated with your Optimizely experiment, then click Apply at the bottom.
- 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".
- When custom segments are selected, your data is split up by the Optimizely Experiment/Variation combination that's 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'
Finished implementing this integration but need to troubleshoot, or notice some discrepancies in the data? See our article on troubleshooting for more information!
Have a question about integrating Optimizely with your Analytics Platform? Head over to the Optimizely questions on Stack Overflow to post a discussion and see what others are talking about.