Skip to content

Integrate with Analytics Platforms

⏱ 20 minutes intermediate

Optimizely’s results page gives you statistical significance and lift. Your analytics platform gives you the broader context — session duration, bounce rates, funnel behavior, and attribution. By sending experiment data to analytics, you can answer questions like “Did the winning variation also improve time on site?” or “Which traffic sources responded best to the variation?” without switching tools.

At minimum, send two values for each experiment:

Data pointPurpose
Experiment name or IDIdentifies which experiment the visitor is in
Variation name or IDIdentifies which variation the visitor is seeing

Some teams also send the experiment status (running, paused) and the campaign or project name for organizational filtering.

MethodBest forSetup effort
Built-in integrationGA4, Adobe Analytics — one-click setupLow
Custom analytics integrationAny platform via JavaScript callbacksMedium
Tag managerGTM, Tealium — route data through your tag layerMedium

Optimizely has a native integration that sends experiment and variation data as GA4 custom dimensions.

  1. In Optimizely, navigate to Settings > Integrations
  2. Find Google Analytics 4 and click Enable
  3. Configure the dimension mapping:
    • Experiment ID dimension — Choose or create a custom dimension in GA4 (e.g., optimizely_experiment)
    • Variation ID dimension — Choose or create a second custom dimension (e.g., optimizely_variation)
  4. Save the integration

Data begins flowing on the next page load. In GA4, create segments or comparisons using these custom dimensions to analyze experiment performance.

  1. Navigate to Settings > Integrations
  2. Enable Adobe Analytics
  3. Map experiment and variation data to Adobe eVars:
    • Select the eVar for experiment ID
    • Select the eVar for variation ID
  4. Save — Optimizely will set the eVars via the s object on each page load

For platforms without a built-in integration, use the Optimizely JavaScript API to read active experiments and send data to any analytics tool.

Send experiment data to a custom analytics platform
javascript
// Wait for Optimizely to be ready
window.optimizely = window.optimizely || [];
window.optimizely.push({
  type: 'addListener',
  filter: { type: 'lifecycle', name: 'activated' },
  handler: function(event) {
    var state = window.optimizely.get('state');
    var activeExperiments = state.getActiveExperimentIds();

    activeExperiments.forEach(function(experimentId) {
      var variation = state.getVariationMap()[experimentId];
      var experimentName = state.getExperimentStates()[experimentId].experimentName;
      var variationName = variation ? variation.name : 'original';

      // Send to your analytics platform
      analytics.track('Experiment Viewed', {
        experiment_id: experimentId,
        experiment_name: experimentName,
        variation_id: variation ? variation.id : 'control',
        variation_name: variationName,
      });
    });
  },
});

If you manage analytics through GTM, push experiment data to the data layer and trigger your analytics tags from there.

Push experiment data to GTM data layer
javascript
window.optimizely = window.optimizely || [];
window.optimizely.push({
  type: 'addListener',
  filter: { type: 'lifecycle', name: 'activated' },
  handler: function() {
    var state = window.optimizely.get('state');
    var experiments = state.getActiveExperimentIds();

    experiments.forEach(function(expId) {
      var variation = state.getVariationMap()[expId];
      window.dataLayer = window.dataLayer || [];
      window.dataLayer.push({
        event: 'optimizely_experiment',
        optimizely_experiment_id: expId,
        optimizely_variation_id: variation ? variation.id : 'control',
        optimizely_variation_name: variation ? variation.name : 'Original',
      });
    });
  },
});

Then in GTM:

  1. Create a Custom Event Trigger for the event name optimizely_experiment
  2. Create Data Layer Variables for optimizely_experiment_id and optimizely_variation_id
  3. Use these variables in your GA4 or Adobe Analytics tags
  1. Open your site with the experiment running
  2. Open browser developer tools
  3. For GA4: Check the Network tab for requests to google-analytics.com containing your custom dimensions
  4. For Adobe: Check the s object in the console for eVar values
  5. For custom/GTM: Check window.dataLayer or your analytics platform’s debug view
ConsiderationDetails
SamplingGA4 may sample data on free accounts. Optimizely does not sample. Numbers may diverge at scale.
Attribution windowOptimizely counts unique visitors per experiment. GA4 may use session-based attribution.
TimingOptimizely activates on snippet load. Analytics tags may fire at different points in the page lifecycle.
User identityOptimizely uses cookies for visitor identity. Ensure your analytics platform uses the same identity basis.
IssueCauseFix
No experiment data in analyticsIntegration not enabled or listener not firingVerify integration settings and check for JavaScript errors
Experiment data appears for wrong pagesExperiment activating on unintended URLsCheck URL targeting in the experiment configuration
Visitor counts differ between toolsDifferent identity models or samplingAccept minor discrepancies as normal; use Optimizely as the source of truth for experiment decisions
Data layer events not firingOptimizely snippet loading after GTMEnsure the Optimizely snippet loads before GTM evaluates