Disclaimer: This website requires Please enable JavaScript in your browser settings for the best experience.

The availability of features may depend on your plan type. Contact your Customer Success Manager if you have any questions.

Dev guideRecipesAPI Reference
Dev guideAPI ReferenceUser GuideLegal TermsGitHubDev CommunityOptimizely AcademySubmit a ticketLog In
Dev guide

Configure Localytics

How to enrich Localytics with Optimizely Feature Experimentation test information.

📘

Note

This is a third-party integration and is not an Optimizely subprocessor. See Optimizely's Third-Party Add-Ons & Platform Integration Terms.

🚧

Important

This integration leverages API behavior that has changed for SDK versions 3.0+. If you encounter any issues, contact Optimizely Support.

Localytics offers more than one option for capturing Optimizely Feature Experimentation test information. The code examples demonstrate the Custom Events with Attributes option in this suggested integration. For more information and alternative solutions, see the sections below.

Android

The example code has two parts:

  • Add a TrackNotificationListener listener for onEvent to wrap Localytics.tagEvent().
  • Add OptimizelyClient.track() to track conversions.

Instead of calling Localytics.tagEvent() directly, wrap the calls with OptimizelyClient.track() to include bucketing information as event attributes.

The example code demonstrates how to add a track event listener. Each OptimizelyClient.track() event tracking retrieves a mapping of experiment key to variation key from UserProfile, which records bucketing decisions. Next, the code calls Localytics.tagEvent() and includes the bucketing map among the attributes.

The last step is to add OptimizelyClient.track() to track event conversions.

Consistent user identity

Maintaining a consistent user identity across multiple sessions and devices can help ensure proper reporting. Localytics provides some guidelines for their platform.

Optimizely Feature Experimentation recommends using the same user ID with these methods:

  • optimizelyClient.activate()
  • Localytics.setCustomerId()

Alternative solution

Another solution is to set Localytics' Custom Dimensions using an ActivateNotificationListener. Custom dimensions can be used to segment users without needing to wrap Localytics.tagEvent(), but they require configuration in the Localytics dashboard for each Optimizely Feature Experimentation test.

import com.localytics.android.Localytics;
import com.optimizely.ab.bucketing.UserProfile;
import com.optimizely.ab.notification.NotificationListener;
import com.optimizely.ab.notification.TrackNotificationListener;
import java.util.Map;

optimizelyManager.getOptimizely().getNotificationCenter().addNotificationListener(NotificationCenter.NotificationType.Track, new TrackNotificationListener() {
 @Override
  public void onTrack(String eventKey, String userId, Map<String, ?> attributes, Map<String, ?> eventTags, LogEvent event) {
    // Make a copy of attributes because it could be immutable
    Map<String, ?> attr = new HashMap<>(attributes);

    // Tag custom event with attributes
    Localytics.tagEvent("[Optimizely] " + eventKey, attr);
  }
});

// Track a conversion event for the provided user
optimizelyClient.track(eventKey, userId);

Compare results

When comparing Optimizely Feature Experimentation and Localytics results, remember to apply a date filter in Localytics that corresponds with the dates your Optimizely Feature Experimentation test was running.

Unsupported Platforms

Optimizely Feature Experimentation does not have a suggested solution for integrating Localytics with our SDKs for these platforms:

  • Agent
  • Go
  • C#
  • Java
  • JavaScript
  • Node
  • PHP
  • Python
  • Ruby