Optimizely integration

Optimizely is a tool that helps businesses improve their digital experiences by running experiments and making optimizations. With Optimizely, organizations can conduct A/B tests and personalize campaigns on their sites.

When you integrate Piwik PRO with Optimizely, you gain easy access to Optimizely stats right within Piwik PRO. This integration enables you to compare the results of your A/B tests, allowing you to make informed decisions based on comprehensive data analysis.

In this article, we’ll walk you through a step-by-step guide on how to integrate Optimizely with Piwik PRO.

Before you start

Here are some important things to keep in mind before you start:

  • This integration is based on a data layer, custom dimensions and custom events. For each Optimizely campaign, you need to create a separate custom dimension and custom event, including separate triggers.
  • You can install Optimizely on your site using our Optimizely Snippet tag.

Integrate Piwik PRO with Optimizely

The integration with Optimizely works by creating a data layer to store Optimizely data. This data layer lets you access Optimizely stats using tags in Piwik PRO. These tags then transfer the data to custom dimensions and custom events, so you can easily see it in your Piwik PRO reports.

To integrate Piwik PRO with Optimizely, follow these steps:

  1. Log in to Optimizely.
  2. Navigate to Settings > Integrations.
  3. Click Create New Analytics Integration.
    Optimizely integration in Piwik PRO
  4. Name your integration and paste the following code:
    var state = window.optimizely.get("state");
    var experimentStates = state.getExperimentStates();
    var experimentName = experimentStates[experimentId].experimentName;
    var variationName = experimentStates[experimentId].variation.name;
    window.dataLayer = window.dataLayer || [];
    window.dataLayer.push({
        'event': campaign.name,
        'experimentName': experimentName,
        'variationName': variationName,
    });
    
    Optimizely integration in Piwik PRO
  5. Save and enable your integration.
    Optimizely integration in Piwik PRO
  6. Navigate to your A/B testing campaign and make sure that your integration is also enabled for it.
    Optimizely integration in Piwik PRO

    Note: You can check if the data is in the data layer using debug mode in Tag Manager in Piwik PRO. Go to Menu > Tag Manager > Debug mode > Data layer.

  7. Log in to Piwik PRO.
  8. Go to Menu > Analytics > Settings.
  9. On the left, click Custom dimensions.
  10. Create a new session dimension. Name it the same way as your campaign in Optimizely. Example: Optimizely campaign: add-to-cart button color.
    Optimizely integration in Piwik PRO

    Note: Create a custom session dimension for each Optimizely campaign you want to see in Piwik PRO.

  11. Go back to Menu > Tag Manager.
  12. Create a variable of the following type: Data layer variable.
  13. Name it Variation name or use another name.
  14. Set the following value for this variable: variationName.
    Optimizely integration in Piwik PRO
  15. Save the variable.
  16. Create another variable of the same type: Data layer variable.
  17. Name it Experiment name or use another name.
  18. Set the following value for this variable: experimentName.
    Optimizely integration in Piwik PRO
  19. Save the variable.
  20. Create a new tag of the following type: Custom event.
  21. Name it the same way as your campaign in Optimizely. Example: Optimizely campaign: add-to-cart button color.
  22. Set the following parameters:
    • Category: Optimizely
    • Action: {{ Experiment name }}
    • Name: {{ Variation name }}
    Optimizely integration in Piwik PRO
  23. Add the custom dimension you created in step 10 to this event and assign the following value to it: {{ Variation name }}.
    Optimizely integration in Piwik PRO
  24. Add a new trigger to this tag. Choose the following trigger type: Data layer event.
  25. Set the following conditions:
    • Event name contains <experiment name used in Optimizely for which you are creating an event>
    Optimizely integration in Piwik PRO

    Note: Create a custom event tag for each Optimizely campaign you want to see in Piwik PRO. Each active A/B test should have its own custom event tag, configured with the correct trigger to match the experiment name. Additionally, custom dimensions should be set in the appropriate slots to prevent data from being overwritten between tests.

  26. Save and publish your tag.
  27. All done! Now your Optimizely stats will be visible in Piwik PRO reports.

Optimizely stats in Piwik PRO reports

Now, we’ll show you how to access your A/B test data from Optimizely in Piwik PRO reports.

To view reports, follow these steps:

  1. Go to Menu > Analytics.
  2. Navigate to Reports.
  3. On the left, pick the following report: Custom dimensions or Custom events. Your Optimizely data will be visible in both of these reports.
    Optimizely integration in Piwik PRO
  4. (Optional) You can also create two kinds of segments to help you analyze data. One for sessions including the selected campaign. Condition: <campaign name> is not.
    Optimizely integration in Piwik PRO
  5. (Optional) And you can create another segment for sessions that include the selected A/B variation. Condition: <campaign name> contains <variation name>.
    Optimizely integration in Piwik PRO

Was this article helpful?

Technical support

If you still have any questions, visit our community.
There’s always someone happy to help!

Back to help center