Optimizely Tracking Module for iOS

Optimizely Tracking Module for iOS

by on ‎06-13-2017 11:03 AM - edited on ‎07-06-2017 08:19 AM by Community Manager (102 Views)

The Optimizely Tracker module for the Tealium iOS library is an integration between Optimizely X and Tealium Collect. The module listens for events triggered by Optimizelylibrary and passes the event data to Tealium Collect.

Table of Contents Placeholder

Installing

The Optimizely Tracker module must be added to your app.download here: 

To install the module into your app: 

  1. Download here: https://github.com/Tealium/tealium-ios/tree/master/Support/Optimizely
  2. Add the "TealiumIOSOptimizely.framework" file into your XCode project (in the "Embedded Binaries" section of your project settings).

Learn more about the Optimizely X library.

Initializing

The Optimizely module must be initialized after the standard Tealium instance is created. See how to initialize the Tealium instance in iOS before proceeding. Initialize the TealiumOptimizelyTracker instance by passing the Tealium instance and providing an instance name:

// Initialize the Tealium Optimizely instance
TealiumOptimizelyTracker * tealOpt = [TealiumOptimizelyTracker tealium];
[tealOpt addInstanceWithName:@"INSTANCE_KEY"];

No additional configuration is needed. The module will now listen for notifications from the Optimizely SDK and pass the data to Tealium Collect as required.

Tracking

There are two types of Optimizely events that will be passed along to Tealium Collect: experiments and custom events. 

These events are captured by Tealilum with the following event names:

  •  tealium_event="Optimizely Experiment Started" - when the Optimizely SDK activates an experiment.
  •  tealium_event="Optimizely Event Tracked" - when the Optimizely SDK receives a custom event (generated by manually calling Optimizely's track method).

Data Layer Variables

The following event attributes are included in the tracked Optimizely events:

Variable Scope Experiment Activation Event Tracking Description
optimizely_experiment_key Volatile (session) X X Optimizely experiment name (e.g. "Homescreen MVT")
optimizely_variation_key Volatile (session) X X Optimizely variation name (e.g. "Variation A")
optimizely_user_id Volatile (session) X X Optimizely user ID (e.g. "ralph@tealium.com")
optimizely_event_key Hit (single event) X X Optimizely event name (e.g. "purchase")
optimizely_event_value Hit (single event) X X Optimizely event value (e.g. "123" - integer values only)
optimizely_XXX Hit (single event) X X Optimizely custom attribute prefix. All custom attributes are prefixed with "optimizely_" and passed directly to Tealium

Overriding default variable names

The default variable names can be overridden if you prefer a different naming convention. To override variable names change the public properties in the TealiumOptimizelyTracker class:

...
TealiumOptimizelyTracker * tealOpt = [TealiumOptimizelyTracker sharedInstance];

[tealOpt addInstanceWithName:@"myinstancename"];
tealOpt.TEOptimizelyUserIdKeyName = @"my_user_id_key";
tealOpt.TEOptimizelyExperimentKeyName = @"my_experiment_name_key";
tealOpt.TEOptimizelyVariationKeyName = @"my_variation_name_key";
tealOpt.TEOptimizelyEventKeyKeyName = @"my_event_name_key";
tealOpt.TEOptimizelyEventValueKeyName = @"my_event_value_key";