HomeGuidesAPI Reference
Submit Documentation FeedbackJoin Developer CommunityOptimizely GitHubOptimizely NuGetLog In
Hey! These docs are for version 2.1.0-full-stack, which is no longer officially supported. Click here for the latest version, 1.0!


Read the [Localytics Getting Started Guide](🔗) if you're getting started.

Localytics offers more than one option for capturing Optimizely 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 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 test.





## Objective-C

The example code has two parts:

  • Add a track event listener to wrap `[Localytics tagEvent]`

  • Add `[optimizely track]` to track conversions

Instead of calling `[Localytics tagEvent]` directly, wrap the calls with `[optimizely track]` to include bucketing information as event attributes.

The example code demonstrates how to add the track notification listener. Each `[optimizely track]` event tracking adds a mapping of experiment key to variation key to the event attributes and passes the mapping to `[Localytics tagEvent]`.

The last step is to add `[optimizely 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 recommends using the same user ID with these methods:

  • `[optimizely activate]`

  • `[Localytics setCustomerId]`

#### [Alternative solution](🔗)

Another solution is to set Localytics' [Custom Dimensions](🔗) using an activate notification listener. 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 test.





## Swift

The example code has two parts:

  • Add a track notification listener to wrap `Localytics.tagEvent()`

  • Add `optimizely.track()` to track conversions

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

The example code demonstrates how to add a track notification listener. Each time `optimizely.track()` event tracking adds a mapping of experiment key to variation key to the event attributes and pass the mapping to `Localytics.tagEvent()`.

The last step is to add `optimizely.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 recommends using the same user ID with these methods:

  • `optimizely.activate()`

  • `Localytics.setCustomerId()`

#### [Alternative solution](🔗)

Another solution is to set Localytics' [Custom Dimensions](🔗) using an activate notification listener. Custom dimensions can be used to segment users without needing to wrap `Localytics.tagEvent()` but requires configuration in the Localytics dashboard for each Optimizely test.





## Compare results

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

## Unsupported Platforms

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

  • C#

  • Java

  • JavaScript

  • Node

  • PHP

  • Python

  • Ruby