This article will help you:
  • Integrate Google Universal Analytics to read data from Optimizely's iOS and Android experiments
  • Track GA metrics as experiment goals

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 for iOS and Android.


Are you looking for a different Google Analytics Integration? If so, check out our article on implementing Google Analytics Classic or Google Universal Analytics.

Begin by going to the Integrations tab on the Home page. Select either Google Analytics or Universal Analytics and toggle the button to ON in the details sidebar to the right.

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


Implementing Optimizely and Google Analytics in a tag manager? Read the tag manager section of our article on implementing Optimizely to find out more about how this will affect your GA tracking code.

Enable integration


  1. Write down your tracking ID from Property Settings.

  2. In your GA dashboard, click Custom Definitions > Custom Dimension > New Custom Dimension and enter the experiment you wish to track.

  3. Also note the Index for this experiment, as you will be using this value in the Integrations menu in the Optimizely Editor.

  4. In the Optimizely Editor, click Options > Integrations.
  5. Toggle on Universal Analytics SDK: for iOS and select a custom dimension that you want your experiment to send data to. This custom dimension is the same as the slot you have set in your Google Analytics dashboard.
  6. Save your experiment.

When toggling on this integration, you may need to wait up to five minutes due to propagation delay.


While our recommended integration is scoped at the session level, you can also configure your integration to be scoped at the user level.

Ultimately, you'll need to choose the scoping that's better for the types of conversions you want to track. For instance, session-level scoping may be better if the experiment is running sitewide or if a visitor will always go back through the experiment pages before converting. But user-level scoping may be better if it's possible for a user to leave the site, then come back and convert without seeing the experiment again.

Our default integration uses session scope to minimize the possibility of overwriting your experiment data sent to Google Analytics, but if you're tracking complex conversions that span multiple sessions, you may prefer to scope at the user level. For more information, see Google's documentation on scoping.

If you do this, just be cautious of reusing Custom Dimensions in Google Analytics, and for consistency between Google Analytics and Optimizely's Results page, set the Google Analytics reporting range to the duration that your experiment ran.


Adding a Tracker

In your Xcode (iOS) or Android Studio (Android) project, with the GA for iOS or Android SDKs installed, instantiate a tracker with your tracking ID that matches the property you created in the dashboard.

A sample setup in your AppDelegate (iOS) looks like this:

For Android, this is a sample setup to instantiate your tracker:

Tracker tracker = GoogleAnalytics.getInstance(this).newTracker("TRACKER_ID");

Make sure to instantiate your tracker before you start Optimizely.


You can now use the Google Analytics API to start tracking events that occur in your app. For iOS, your code may look like this:

For Android, your code may look like this:

HashMap<String, String> hitParameters = new HashMap<String, String>();
hitParameters.put(Fields.HIT_TYPE, "appview");
hitParameters.put(Fields.SCREEN_NAME, "Home Screen");


For more information on how to configure setting and sending data, consult Google’s Developer Docs.

Verify installation

  1. On iOS, enable GA verbose logging for QA purposes by entering
    [[GAI sharedInstance].logger setLogLevel:kGAILogLevelVerbose];

    before the GAITracker. This protocol is provided to handle useful messages from the SDK at these levels of verbosity: error, warning, info, and verbose

    On Android, use this code to enable verbose logging:

    // Set the log level to verbose.

  2. Now rebuild your app and verify in Xcode (iOS) or Android Studio (Android) log statements that experiment data is successfully being sent to GA.

  3. You’re done! Your app will now send Optimizely experiment and variation information to your Google Analytics account whenever an event is triggered! These can be seen in real time from the GA dashboard when an event triggers.

  4. Log into your Universal Analytics account and click the Customization tab at the top. You should see a Custom Reports list that looks something like this: 

  5. Set up a Custom Report for each experiment you have integrated Universal Analytics with. To do this, click New Custom Report. Then give the report a title and add the metric groups you wish to view in the report.
  6. To filter this report for only your Optimizely experiment, choose the Custom Dimension you set up previously as one of the Dimension Drilldowns. See the below image for an example.
  7. Add this dimension in the Filters section and use a Regex match on the experiment name for the experiment you want to filter. This will ensure that only Universal Analytics data for that particular experiment is shown in your report:


    Make sure to leave Filters empty when creating a custom report for an iOS or Android experiment.

  8. Click Save. You'll then be able to access your report and update the date filter if you wish:



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.