Skip to main content

We are currently experiencing an issue that is preventing customers from submitting support tickets. Please contact us at (866) 819-4486 if you need immediate assistance.

x
Optimizely Knowledge Base

Integrating Optimizely with Localytics for iOS and Android

This article will help you:
  • Integrate Localytics to read experiment data in Optimizely for iOS and Android
  • View and analyze your Optimizely metadata in Localytics
  • Verify your Localytics integration for iOS and Android

With this integration, you can analyze and take action on in-app events and user profiles in Localytics, based on visitors who enter your Optimizely experiments. You'll also be able to target push notifications and other marketing strategies to customers who see a particular experiment or variation.

Prerequisites for this integration:

Enable Localytics in Optimizely

To enable the Localytics integration, go to the Integrations tab on the Home page. Select Localytics and toggle the button to ON.

Locate your Localytics App Key

In the Localytics Dashboard, navigate to Settings. Locate the app you’re integrating with Optimizely. Copy the key to your clipboard.

Set up your integration on iOS

After the Optimizely and Localytics SDKs are both installed and you have your App Keys available, simply call these methods in your app’s AppDelegate with the App Keys inserted.

In your project's App Delegate, place the following code in didFinishLaunchingWithOptions. Please note that the order of operations does matter in this case.  As of v1.4 of the Optimizely iOS SDK, the activateLocalyticsIntegration call is not required.

[Localytics autoIntegrate:myLocalyticsToken 
            launchOptions:launchOptions];

// The next line of code is only required for versions of the Optimizely SDK 1.3.2 and below
[Optimizely activateLocalyticsIntegration];

[Optimizely startOptimizelyWithAPIToken:myOptimizelyToken                                      launchOptions:launchOptions];

Set up your integration on Android

First, declare a dependency on the Optimizely Localytics Integration in your app’s build.gradle file.

dependencies {
    compile('com.optimizely:localyticsintegration:+@aar')
}


After the Optimizely and Localytics SDKs are both installed and you have your App Keys available, simply call these functions in your app’s AppDelegate with the App Keys inserted. The order of these methods does not matter.

public MainActivity extends Activity  {
    public void onCreate(Bundle b) {
       super.onCreate(b);
       Optimizely.startOptimizely(“Your API Token”, getApplication();
    }
}

View Optimizely data in Localytics

To view an Optimizely Experiment as an event in Localytics, click Events in the Localytics Dashboard.

If you’re tracking a funnel in Localytics, click Funnels in the Localytics Dashboard and you’ll be able to see when your users have visited an Optimizely Experiment.

You can create a target audience in Localytics to segment your users by Optimizely Experiments. Click Audiences in your Localytics Dashboard to create a new audience.

Verify your Android installation

  1. To QA your integration, enable Optimizely verbose logging before starting your experiment. In the code, add the following:
     
    public MainActivity extends Activity {
        public void onCreate(Bundle b) {
            super.onCreate(b);
    
            Optimizely.setVerboseLogging(true);
            Optimizely.startOptimizely(“Your API Token”, 
            getApplication();
        }
    }

     
  2. You should also enable Localytics logging.  In the code, add the following:
     
    public class MyApp extends Application {
        public void onCreate() {
            Localytics.integrate(this);
            Localytics.setLoggingEnabled(true);
        }
    }
    

     
  3. Now rebuild your app and verify in the Android Studio log statements that your experiment data is being successfully sent to Localytics. If your setup is correct, you should see the following:
     
    D/Optimizely Logging: [localytics_mobile] Activating Plug
    D/Optimizely Logging: [Optimizely Localytics Integration] Add profile attribute for experiment: test1, variation:Origin
    D/Optimizely Logging: [localytics_mobile] Plugin Activated Successful
    

Verify iOS installation

  1. To QA your integration, enable Optimizely verbose logging before starting Optimizely. Enable verbose logging with the following line of code:
     
    [Optimizely sharedInstance].verboseLogging = YES

     
  2. Now rebuild your app. If your experiment data is being successfully sent to Localytics, you should see the following code in the XCode log.