relevant products:
  • Optimizely X Web Experimentation
  • Optimizely X Web Personalization
  • Optimizely X Web Recommendations
  • Optimizely Classic

This article will help you:
  • Integrate Google Universal Analytics to read data from Optimizely  
  • Add Google Universal Analytics integration code to your page
  • Track Google Universal Analytics metrics as experiment goals
  • Create custom dimensions and reports in Google Universal Analytics to track and report on Optimizely data

If you use Google Universal Analytics (UA) to monitor your site's traffic, you can view the results of your Optimizely experiments alongside the rest of the data that Google UA collects.

Here are a few reasons to integrate:

  • Get a direct view of how Optimizely experiments affect the metrics you track in Google Analytics
  • See Google Analytics data for each variation in your experiment (or experience in a campaign)
  • Filter your Google Analytics reporting by visitors who were successfully included in an Optimizely experiment and exclude those who weren't

Looking for a different Google Analytics integration? See our articles on implementing Google Analytics Classic or Google Analytics for iOS. Or, go to our Google Tag Manager article.

To learn more, you can also check out these great write-ups by our Solutions Partners Swell Path and Vertical Nerve; and Geoff Kenyon.

Troubleshooting your Google UA integration or seeing discrepancies in your reports? See our GA troubleshooting article.

Integrate Google UA with Optimizely X Web

We've updated the Google UA integration for Optimizely X Web. Now it's even easier to integrate Optimizely with Google UA!

Here's what you need to know:

  • In Optimizely X Web, you can choose any order for the Optimizely and Google UA snippets.

  • Optimizely X Web no longer sends Optimizely data with the 'pageview'. It sends a separate 'non-interaction event', independent of the 'pageview'.

  • When a decision event is made, Optimizely X Web sends that event to Google UA as soon as possible, polling for availability of the Google UA object.

    If the Google UA object isn't ready when a decision is made, Optimizely X Web checks back every 200 ms to see if Optimizely can send the UA string. This helps with delayed activation experiments (and if they fall under delayed activation, it helps with geo-targeted experiments too).

  • You no longer need to add the API call activateUniversalAnalytics. But it's fine to leave it in your code, and it's a good idea to leave it if you're still using Optimizely Classic


Ready to get started? First, you'll need to enable Google Analytics.

Here's how:

  1. Navigate to the project's Home page and select the Integrations tab.

  2. Select Google Analytics and toggle it On.

    That's it! 

  3. See how to enable integrations in Optimizely X Web.

    To enable Google Analytics for an individual experiment in Optimizely Classic, navigate to the experiment in the Visual Editor, then click Options > Integrations.

Here are a few other details to keep in mind:

  • To integrate Optimizely with Google UA, you'll need an available custom dimension in Google Analytics to populate with Optimizely experiment data. (The custom dimension in Google Analytics is not the same as the Optimizely feature.)
  • In Optimizely Classic, place the Google UA tracking code at the bottom of the <head> section of your pages. The integration won't work properly unless the Optimizely snippet is above the Google UA snippet.
  • Use the number (or index) of the custom dimension to configure and send data to your Optimizely experiment. (To access your Google UA custom dimensions and create one for Optimizely, create a custom dimension.) 
  • Use one custom dimension per concurrently running experiment or campaign to keep experiment names and variations from overwriting each other.
  • If you have the setDomainName function call on your page, make sure that it doesn't use a leading period or "www".
  • Your Optimizely experiment or campaign must be running for Google UA integration to work.
  • As long as you're testing on the same domain and Optimizely is implemented on the experiment page, you can track session-wide goals in Google UA.