Optimizely X Tracking Module
Provides an integration between Optimizely X and Tealium Collect. The module listens for events triggered by the OptimizelyX library and passes the event data to Tealium Collect.
Requirements
- Optimizely X Android SDK added to your app
Install
Install the Optimizely X Tracking module with Maven or manually.
Maven
To install the Optimizely X Tracking module with Maven:
-
In your project’s top-level
build.gradle
file, add the following Maven repository:maven { url "https://maven.tealiumiq.com/android/releases/" }
-
In your project module’s
build.gradle
file, add the following Maven dependency:dependencies{ //only required if you do not have this reference implementation 'com.tealium:library:5.8.0' implementation 'com.tealium:optimizelylistener:1.1.2' //only required if you do not already have this reference and require lifecycle tracking implementation 'com.tealium:lifecycle:1.1.4' }
Manual
To install the Optimizely X module manually:
-
Download the Tealium OptimizelyListener module.
-
In your top-level
build.gradle
file, verify the following:allprojects { repositories { mavenCentral() flatDir { dirs 'libs' } } }
-
Copy the file
tealium.optimizelylistener-1.1.1.aar
into your project’s<PROJECT_ROOT>/<MODULE>/libs
directory. -
Add the Tealium library dependency to your project module’s
build.gradle
file:dependencies { // only required if you do not already have this reference implementation(name:'tealium-5.6.1', ext:'aar') implementation(name:'tealium.optimizelylistener-1.1.1', ext:'aar') // only required if you do not already have this reference and require lifecycle tracking implementation(name:'tealium.lifecycle-1.1.2', ext:'aar') }
Initialize
The module must be initialized after the OptimizelyManager
has finished initializing. If initialized elsewhere, some or all events may not be tracked.
Optimizely
provides a listener which is called as soon as the OptimizelyManager
is initialized.
// import the Tealium OptimizelyListener module in the import section
import com.tealium.optimizelylistener.TealiumOptimizelyEventListener;
//...
// substitute the example instance name here with the same instance name you used when initializing the Tealium library
private static final String TEALIUM_INSTANCENAME = "teal";
myOptlyManager.initialize(getApplicationContext(), new OptimizelyStartListener() {
@Override public void onStart(OptimizelyClient optimizely) {
// call this to init the Optimizely listener with a valid OptimizelyManager instance
// myOptlyManager is your own reference to the global OptimizelyManager instance
TealiumOptimizelyEventListener.init(TEALIUM_INSTANCENAME, myOptlyManager);
// activate experiment AFTER initializing the Tealium listener.
// tracking calls are missed if not done in this order.
Variation v = optimizely.activate("tealiumtest", "userid");
}
});
Once you have initialized the module, no additional configuration is required. The module listens for notifications from the Optimizely
SDK and pass the data to the Tealium SDK as required.
Auto-Tracked Events
There are two types of Optimizely
events are passed along to Tealium Collect: experiments and custom events.
These events are set in the tealium_event
variable with the values:
- Optimizely Experiment Started
When theOptimizely
SDK activates an experiment. - Optimizely Event Tracked
When theOptimizely
SDK receives a custom event (generated by manually callingOptimizely
’strack
method).
Data Layer
The following event attributes are included in the tracked Optimizely
events:
Variable | Scope | Description | Example |
---|---|---|---|
optimizely_ experiment_key |
Volatile (session) | Optimizely experiment name |
"Homescreen MVT" |
optimizely_ variation_key |
Volatile (session) | Optimizely variation name |
"Variation A" |
optimizely_ user_id |
Volatile (session) | Optimizely user ID |
"[alice@tealium.com](mailto:alice@tealium.com)" |
optimizely_ event _key |
Hit (single event) | Optimizely event name |
"purchase" |
optimizely_ event _value |
Hit (single event) | Optimizely event value |
"123" (integers only) |
optimizely_ XXX |
Hit (single event) | All Optimizely custom attributes are prefixed with "optimizely_" and passed directly to Tealium |
Variable Name Overrides (optional)
The default variable names are overridden easily if you prefer a different naming convention. Overriding variable names is done by changing a set of public properties on the TealiumOptimizelyEventListener
class.
import com.tealium.optimizelylistener;
//...
TealiumOptimizelyEventListener.OPTIMIZELY_EXPERIMENT_KEYNAME = <your new value>;
TealiumOptimizelyEventListener.OPTIMIZELY_VARIATION_KEYNAME = <your new value>;
TealiumOptimizelyEventListener.OPTIMIZELY_USERID_KEYNAME = <your new value>;
TealiumOptimizelyEventListener.OPTIMIZELY_EVENTKEY_KEYNAME = <your new value>;
TealiumOptimizelyEventListener.OPTIMIZELY_EVENTVALUE_KEYNAME = <your new value>;
TealiumOptimizelyEventListener.OPTIMIZELY_EXPERIMENT_STARTED = <your new value>;
TealiumOptimizelyEventListener.OPTIMIZELY_EVENT_TRACKED = <your new value>;
TealiumOptimizelyEventListener.OPTIMIZELY_ATTRIBUTE_PREFIX = <your new value>;
API Reference
For the complete reference of methods for the Optimizely X Tracking Module, see the TealiumOptimizelyEventListener
class in the Tealium SDK for Android API.
This page was last updated: November 7, 2018