Description
The browser-plugin-optimizely-x plugin does not capture campaignId
for Optimizely Personalization campaigns. After extensive investigation
across 100,000+ sessions over 23 days on a live Personalization campaign,
no Campaign IDs were present in the Snowplow event data.
Root Cause
The plugin's getOptimizelyXSummary() function uses the wrong Optimizely
state API:
var experiment_ids = state.getActiveExperimentIds() || [];
var variationMap = state.getVariationMap();
getActiveExperimentIds() does not surface the campaign layer at all.
In Optimizely's data model, Personalization campaigns are structured as:
Campaign (layerId / campaignId)
└── Experience (surfaces as experiment.id in getCampaignStates)
└── Variation
The correct API is getCampaignStates({ isActive: true }), which returns
a keyed object where:
- The top-level key is the
campaignId (layerId)
campaign.experiment.id is the experience ID (for Personalization)
or experiment ID (for Web Experimentation)
campaign.variation.id and campaign.variation.name are directly
available
This affects all Optimizely Personalization campaign users —
campaignId is never captured regardless of configuration, privacy
settings, or campaign status.
Additional Issue
For Web Experimentation, campaignId and experimentId are the same
value so Web Experimentation users are not impacted by missing data,
but they are also not getting campaignId surfaced explicitly.
Expected Behavior
The plugin should capture campaignId for all Optimizely campaign types,
correctly mapping:
campaignId — the Optimizely layer ID
experimentId — the experiment or experience ID
variationId / variationName — the assigned variation
Proposed Fix
Replace getActiveExperimentIds() with getCampaignStates({ isActive: true })
and add campaignId to the OptimizelyxSummary interface and schema.
A working fix has been built and verified in the browser against a live
Personalization campaign. A PR is ready to accompany this issue.
Environment
- Plugin version: 4.6.9
- Optimizely product: Web Experimentation + Personalization
- Verified against: Live Personalization campaign, 100k+ sessions
---
## 2. Pull Request Description
**Goes to:** GitHub > Your Fork > Pull Requests > New Pull Request (targeting snowplow main branch)
**Title:**
fix(optimizely-x): use getCampaignStates to capture Personalization campaignId
Description
The
browser-plugin-optimizely-xplugin does not capturecampaignIdfor Optimizely Personalization campaigns. After extensive investigation
across 100,000+ sessions over 23 days on a live Personalization campaign,
no Campaign IDs were present in the Snowplow event data.
Root Cause
The plugin's
getOptimizelyXSummary()function uses the wrong Optimizelystate API:
getActiveExperimentIds()does not surface the campaign layer at all.In Optimizely's data model, Personalization campaigns are structured as:
The correct API is
getCampaignStates({ isActive: true }), which returnsa keyed object where:
campaignId(layerId)campaign.experiment.idis the experience ID (for Personalization)or experiment ID (for Web Experimentation)
campaign.variation.idandcampaign.variation.nameare directlyavailable
This affects all Optimizely Personalization campaign users —
campaignIdis never captured regardless of configuration, privacysettings, or campaign status.
Additional Issue
For Web Experimentation,
campaignIdandexperimentIdare the samevalue so Web Experimentation users are not impacted by missing data,
but they are also not getting
campaignIdsurfaced explicitly.Expected Behavior
The plugin should capture
campaignIdfor all Optimizely campaign types,correctly mapping:
campaignId— the Optimizely layer IDexperimentId— the experiment or experience IDvariationId/variationName— the assigned variationProposed Fix
Replace
getActiveExperimentIds()withgetCampaignStates({ isActive: true })and add
campaignIdto theOptimizelyxSummaryinterface and schema.A working fix has been built and verified in the browser against a live
Personalization campaign. A PR is ready to accompany this issue.
Environment
fix(optimizely-x): use getCampaignStates to capture Personalization campaignId