Optimizely
Overview
Lytics offers two ways to bring your audiences into Optimizely, depending on which Optimizely product you use:
- Optimizely X Experimentation — Lytics defines a matching audience in Optimizely X for each Lytics audience, resolved client-side from the
ly_segscookie. Use this to run classic Optimizely X Web/Full Stack experiments against your Lytics audiences. - Optimizely Data Platform (ODP) — Lytics writes audience membership as a boolean attribute on each ODP customer profile, which you then use to build Real-Time Segments in Feature Experimentation. This is the path Optimizely recommends for powering Feature Experimentation with CDP audiences.
Each path is self-contained below — with its own authorization and job — and the two can be used independently or together.
Optimizely X Experimentation
Get the most out of Optimizely X by running experiments against any of your Lytics audiences.
Because Optimizely uses a synchronous tag that blocks page load and Lytics uses an asynchronous tag that will never affect page load, natively running experiments on the first page view for first time visitors is not recommended.
Authorization
- Select
Account->Security->Authorizationsfrom the left side menu. - Click
+ Create Newat the top of the list. - Select
Optimizely. - Select
Optimizely X Oauth - Log in to Optimizely when prompted.
- Complete the authorization by adding a description.
This integration no longer supports "Optimizely Classic."
How it Works
- When someone visits a web property with the Lytics tag installed, Lytics will identify who they are and return a list of audiences they are currently a member of in real-time. This process happens very quickly but is asynchronous, meaning it is designed to never negatively impact performance.
- Once those profiles have been received, the audiences are stored in a cookie called
ly_segs. This cookie is then updated, asynchronously, on every subsequent page view. - You will then set up a sync job between Optimizely X and Lytics from the Lytics interface. This ensures a set of audiences are automatically defined within Optimizely X which look for a membership map to the audiences stored in this cookie.
- Optimizely experiments are then configured to target your Lytics powered audiences.
Create Audiences
Running this workflow will create an audience in Optimizely for each Lytics audience that has been API enabled.
Integration Details
- Implementation Type: Server-side Integration.
- Implementation Technique: REST API Integration .
- Frequency: Batch Integration every hour.
- Resulting data: Optimizely Audience.
This integration utilizes Optimizely APIs to create audiences. On each run of the job, it will:
- For each Lytics audience marked as API enabled an audience will be created in Optimizely with the name "Lytics" + audience name, and with the condition of a substring match of the key
ly_segsand value of the corresponding audience slug. - The work will run continousouly. As new public audiences are created in Lytics, audiences will be created in Optimizely every hour.
Configuration
Follow these steps to set up and configure the export audience job for Optimizely in the Lytics platform. If you are new to creating jobs in Lytics, see the Jobs Dashboard documentation for more information.
- Click
Data Pipeline->Jobsfrom the left side menu. - Click
+ Create Newat the top of the list. - Select
Optimizely. - Select
Create Audiences. - Select the authorization created above.
- Add a
LabelandDescriptionand then clickCompleteat the bottom right.
After a few minutes visit the Audiences section of your Optimizely account to verify that the Lytics audiences are configured correctly.
Configure ly_segs Cookie Storage
As of version 3 of the Lytics JavaScript tag, audience membership is no longer actively stored as a cookie by default. This means that in order to facilitate the communication between Optimizely and Lytics you will need to install this additional code snippet on your website. Be sure to load this tag after the core Lytics JavaScript tag.
jstag.call('entityReady',function(p){var segments=[];if(p&&p.data&&p.data.user){segments=p.data.user.segments;}else if(p&&p.data&&p.data.segments){segments=p.data.segments;}if(segments.length>0){var t=JSON.stringify(segments);console.log(t);jstag.setCookie("ly_segs",t,604800);}else{console.warn("Unable to locate customer profile data or segment membership for personalization.");}});Configuring Experiments
Once you have configured your audience following the steps above all that is left is to configure and test your experiment. Refer to the Optimizely documentation for associating an audience with an experiment.
Optimizely Data Platform (ODP) Audience Export
Export your Lytics audiences to the Optimizely Data Platform (ODP) to power Real-Time Segments in Feature Experimentation with CDP audiences. Lytics writes audience membership onto each ODP customer profile, you build an ODP Real-Time Segment from that attribute, and the Feature Experimentation SDK evaluates the segment at runtime.
When a user enters a synced Lytics audience, Lytics sets a boolean attribute on their ODP profile to true; when they exit, it sets the attribute to false. Each audience maps to its own attribute, so multiple audiences can be exported independently without interfering with one another.
Authorization
To connect Lytics and ODP you will need an ODP API key. Generate a private API key from your ODP account. Lytics validates the key when the authorization is saved, and the ODP region is determined automatically from the key, so no region setting is required.
Follow the steps below to add this authorization in Lytics:
- Select Optimizely from the list of providers.
- Select the Optimizely Data Platform API Key method for authorization.
- In the Label text box, enter a name for the authorization.
- (Optional) In the Description text box, enter a description for this authorization.
- In the API Key password box, enter your ODP API key.
- Click Save Authorization.
Export Audiences
Export your Lytics audiences to ODP so you can build Real-Time Segments and target users in Feature Experimentation based on their Lytics audience membership.
Integration Details
- Implementation Type: Server-side Integration.
- Implementation Technique: REST API Integration with Audience Trigger Integration.
- Frequency: Real-time Integration with an optional one-time Backfill of the audience after job setup.
- Resulting Data: User Profiles that are members of the selected audience are written to ODP. Each audience is represented on the ODP customer profile as a boolean attribute named after the Lytics audience slug (prefixed,
lytics_by default), set totruewhile the user is a member andfalseonce they exit.
This integration uses ODP's /v3/profiles API to update customer profiles. Once the export is started, the job will:
- Provision the audience's boolean attribute (for example,
lytics_my_segment) on the ODPcustomersobject so the field exists before any profiles are sent. This runs once at job setup and is safe to repeat. - Run a one-time backfill of the current members of the selected audience, if Existing Users is enabled.
- Receive real-time updates when a user enters or exits the selected audience.
- For each user entering the audience, send the user's identifiers and set the audience attribute to
true. - For each user exiting the audience, set the audience attribute to
false.
Users are sent to ODP in batches of up to 100 profiles per request.
Each Lytics audience is exported as its own boolean attribute rather than as a single multi-value list. ODP replaces (rather than merges) a list attribute on each write, so giving every audience an independent boolean ensures syncing one audience never clobbers another.
Fields
Every exported user must include at least one ODP identifier so ODP can match the user to a customer profile. You map Lytics user fields to ODP identifiers in the job configuration. ODP accepts the following canonical identifiers:
- Email (
email) - Customer ID (
customer_id) - Visitor ID / VUID (
vuid)
At least one identifier must resolve for a given profile, or that user is skipped.
Configuration
Follow these steps to set up and configure an audience export to ODP from Lytics. If you are new to creating jobs in Lytics, see the Destinations documentation for more information.
- Select Optimizely from the list of providers.
- Select the Optimizely: Data Platform Audience Export job type from the list.
- Select the Authorization you would like to use or create a new one.
- Enter a Label to identify this job you are creating in Lytics.
- (Optional) Enter a Description for further context on your job.
- From the Audience input, select the Lytics audience to sync to ODP.
- From the Identifier Mapping input, map Lytics user fields to ODP identifiers by selecting the Lytics field on the left and its ODP identifier on the right. At least one identifier mapping is required.
- (Optional) In the Attribute Prefix text box, change the prefix added to the audience slug to form the ODP attribute name. Defaults to
lytics_, so audiencemy_segmentbecomes the attributelytics_my_segment. - (Optional) From the Audience Trigger Events input, select which transitions to send: Enters and Exits (default), Enters Only, or Exits Only.
- (Optional) Select the Existing Users checkbox to enable a one-time backfill of the current members of the selected audience to ODP immediately. This is enabled by default.
- Click Start Export.
Users will begin appearing in ODP within a few minutes of starting the export. To use the audience in Feature Experimentation, build a Real-Time Segment in ODP that matches profiles where the audience attribute (for example, lytics_my_segment) equals true, then target that segment in your experiment or flag.
