Using Optimizely with Google Analytics

Google Analytics allows you to monitor your website traffic, whereas Optimizely runs experiments. You can view the data from both side by side by integrating Optimizely with Google Analytics. This will enable you to see how Optimizely experiments impact other metrics, view data for variations in experiments, and filter Google Analytics reporting according to which visitors you successfully included in an experiment.

Integration between Google Analytics and Optimizely only works if your Optimizely experiments are active and on the same domain and if Optimizely is implemented on the experiment page.

Setting Up

Before you do anything, you need to enable Google Analytics in Optimizely. You will find this option under “Integrations.” Similarly, you need to set up Optimizely in Google Analytics. This involves creating a custom dimension to populate with experiment data.

If you are using Optimizely Classic, the Google Analytics tracking code needs to be at the bottom of the “<head>” section of your pages. If you are in Optimizely X, code can be anywhere.

Lastly, make sure that you have setDomainName function call on the page and that there is no “www.” at the beginning.

Integrating Google Analytics

Once you have the above set up, you can start the integration process. Choose an Optimizely experiment and pick the Google Analytics custom dimension you want. You need to use the number of the custom dimension to configure and send data to the Optimizely experiment. Use a different dimension for each experiment — this will avoid names and variations overwriting one another.using-optimizely-with-google-analytics-1Although Google will offer you an example of JavaScript for the page, there is no need to include it. In fact, using it could end up overwriting your integration.

Next, decide on an event tracker. You can use the default or enter a custom one into “Custom Tracker (optional).”

With Optimizely Classic, there is an extra step to finish integration: placing API call code. Add this code after the “ga(‘create’ . . . )” function fires but before “ga(‘send’, ‘pageview’)” and tracking call. Find this tracking code in your Google Analytics account by looking for “Tracking Info” and then “Tracking Code” in the “Admin” menu.

The API call code will apply to all active experiments configured with Google Analytics integration. An exception can be experiments using manual or conditional activation. For these, you should re-activate the API call and send a Google Analytics non-integration event after you begin the experiment.

Custom Reports

To view the reports on your experiments in Google Analytics, you need to create a custom report for each. Find the option to create reports in your Google Analytics account under “Customization.” Give each “New Custom Report” a unique title and add the metric groups that would be useful.

In “Dimension Drilldowns,” you need to choose the custom dimension that relates to the experiment. Add this again under “Filters.” Next in the filters section, choose “Regex” and add the correct Optimizely experiment ID, except for Optimizely X Web Personalization, where you should filter for campaign ID.

If you are creating a custom report for an iOS experiment, skip all the instructions about filters and leave the section blank.using-optimizely-with-google-analytics-2

Check the Custom Dimension

Although it takes up to 24 hours to populate events and page view data into Google Analytics, custom dimensions are set immediately. In other words, there is no need to wait to check integration.

To check your custom dimension, you will need the debugger tool. Look for the variable “cd[x]” followed by the variation you were bucketed into. In this example, “x” is the slot that corresponds to your Optimizely experiment.

Integrating Optimizely with Google Analytics helps you get more out of your data. As the process is so simple and require so little time, there is no excuse not to set it up.

If you like my articles,