Introduction
If you use Google Analytics (GA) to monitor your site's traffic, you can now view the results of your Optimizely experiments alongside the rest of the data that GA collects. In this section, we'll explain how this works, and how you can set it up (it's pretty simple).
Implementation Instructions
Setting up Google Analytics
A Google Analytics account must be created and implemented correctly on your site. 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 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.
The latest tracking code can be obtained from the Google Analytics site under Analytics Settings > Profile Settings > Tracking Code.
Enabling Google Analytics Integration
Google Analytics Integration can be enabled for each experiment from the Optimizely "Options" menu by clicking on the 'Analytics Integration' menu item:
Note your Optimizely code snippet must be placed at the top of the <head> section, and your Google Analytics tracking code must be placed at the bottom of the <head> section.
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.
.setDomainName
Make sure that if you have the setDomainName function call on your page it is not using a leading period.Use .setDomainName("mydomain.com"); instead of .setDomainName(".mydomain.com");
The reason we ask you to do this is because when the Optimizely integration is turned on we use the .setCustomVar() function. This function sets a cookie on the domain without the leading period. Calling setDomainName() with the leading period causes this cookie to get overwritten and this could have a negative impact on your referrers and your bounce rate in GA.
The solution is to use setDomainName() without the leading period or to make sure that the Optimizely snippet comes *after* the setDomainName() call but *before* the trackEvent() call.
For more information take a look at http://www.roirevolution.com/blog/2011/01/google_analytics_subdomain_tracking.php
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, the "default" tracker.
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:
http://code.google.com/apis/analytics/docs/gaJS/gaJSApi_gaq.html
http://code.google.com/apis/analytics/docs/tracking/asyncUsageGuide...
Viewing Data
To view data in Google Analytics, click on 'Advanced Segments' and then on the 'Create Custom Segment' button.
Click on 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. 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). Now add another metric using the 'And' condition and select 'Custom Variable (Value X)' where X corresponds to the X from the experiment metric. You will need to type in the name of the variation.
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 the test.
The easiest way to find the different values for the Custom Variables is to go to Audience -> Custom - > Custom Variables
This will show you the various custom variables that you have set up. Click on the custom variable key associated with your Optimizely experiment. This will show you the possible key values associated with that slot.
Clicking on that variable key you can see all the possible values associated with it.
Once you have those values you can use them to create the advanced segment for each variation.
Once that's done click on "Content" and then on "Site Content" in the left navigation bar. This will show you the different pages that your visitors are being tracked on.
By toggling the Advanced Segments you can see how the different variations are affecting performance on the various pages.
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 to the first 4 characters, and then joined with a tilde (~), such as "blue~green~purpl~red".
When custom segments are selected your data is split up by the Optimizely Experiment/Variation combination that's relevant.