This integration is available for all Optimizely Web plans.
- The latest Optimizely Swift SDK or Optimizely Android SDK must be installed.
- The Google Analytics for iOS or Google Analytics for Android SDK must be installed.
- You have an available custom dimension that Optimizely will use to send data to.
- You have Google Analytics “Mobile app” property with a tracking ID.
- You can create a custom report in Google Analytics.
- For Android, you should have a gradle dependency for the Universal Analytics plugin.
- Go to Settings > Integrations.
- Select either Google Analytics (Classic) or Google Universal Analytics and toggle the integration to On.
- Write down your tracking ID from Property Settings.
- In your GA dashboard, click Custom Definitions > Custom Dimension > New Custom Dimension and enter the experiment you wish to track.
- Also note the Index for this experiment, as you will be using this value in the Integrations menu in the Optimizely Editor.
- In the Optimizely App, click Settings > Integrations.
- Toggle on Google Universal Analytics 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.
When toggling on this integration, you may need to wait up to five minutes due to propagation delay.
- Save your experiment.
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 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.
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"); OptimizelyUniversalAnalyticsIntegration.setTracker(tracker);
Make sure to instantiate your tracker before you start Optimizely Web.
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"); tracker.send(hitParameters);
For more information on how to configure settings and send data, consult Google’s Developer Docs.
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
On Android, use this code to enable verbose logging:
// Set the log level to verbose. GoogleAnalytics.getInstance(this).getLogger() .setLogLevel(LogLevel.VERBOSE);
Now rebuild your app and verify in Xcode (iOS) or Android Studio (Android) log statements that experiment data is successfully being sent to GA.
- 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.
- 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:
- 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.
- 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.
- 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.
- Click Save. You will then be able to access your report and update the date filter if you wish:
Updated 3 months ago