Skip to content

bug: browser-plugin-optimizely-x does not capture campaignId for Optimizely Personalization campaigns #1462

@JamesShebester

Description

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    type:defectBugs or weaknesses. The issue has to contain steps to reproduce.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions