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:
- Log in to Optimizely.
- Navigate to Settings > Integrations.
- Click Create New Analytics Integration.
- 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, });
- Save and enable your integration.
- Navigate to your A/B testing campaign and make sure that your integration is also enabled for it.
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.
- Log in to Piwik PRO.
- Go to Menu > Analytics > Settings.
- On the left, click Custom dimensions.
- Create a new session dimension. Name it the same way as your campaign in Optimizely. Example:
Optimizely campaign: add-to-cart button color
.Note: Create a custom session dimension for each Optimizely campaign you want to see in Piwik PRO.
- Go back to Menu > Tag Manager.
- Create a variable of the following type: Data layer variable.
- Name it
Variation name
or use another name. - Set the following value for this variable:
variationName
. - Save the variable.
- Create another variable of the same type: Data layer variable.
- Name it
Experiment name
or use another name. - Set the following value for this variable:
experimentName
. - Save the variable.
- Create a new tag of the following type: Custom event.
- Name it the same way as your campaign in Optimizely. Example:
Optimizely campaign: add-to-cart button color
. - Set the following parameters:
- Category:
Optimizely
- Action:
{{ Experiment name }}
- Name:
{{ Variation name }}
- Category:
- Add the custom dimension you created in step 10 to this event and assign the following value to it:
{{ Variation name }}
. - Add a new trigger to this tag. Choose the following trigger type: Data layer event.
- Set the following conditions:
Event name contains <experiment name used in Optimizely for which you are creating an event>
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.
- Save and publish your tag.
- 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:
- Go to Menu > Analytics.
- Navigate to Reports.
- On the left, pick the following report: Custom dimensions or Custom events. Your Optimizely data will be visible in both of these reports.
- (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
. - (Optional) And you can create another segment for sessions that include the selected A/B variation. Condition:
<campaign name> contains <variation name>
.