Through the years, we’ve integrated data from Optimizely and Google Analytics in a number of different ways. The method we’re about to share with you is in our experience the best and easiest.
Why would you want to integrate your analysis and testing tools? Because it helps to improve the quality of your test data. Since there is a difference between these tools, you’ll want to make sure that your experiments are as valid as possible.
The “old” (link to post in Swedish) way requires you to remove the Page view tag (in GTM) and that you replace it with a Custom HTML tag. This was an emergency solution that’s not required anymore, since GTM has released long anticipated updates. Now, we’re using GTM the way it should be.
Our recommendations are not the same as Optimizely’s
Please note that this is not what Optimizely themselves recommend… Our way gives you both events and custom dimensions in Google Analytics, which gives you more freedom during the analysis phase. Optimizely’s method only gives you custom dimensions. More about the differences between these recommendations further below.
1Make the integration possible from Optimizely
- Log in to the Optimizely tool
- Go to the “Integrations” tab
- Activate “Google Universal Analytics” through clicking “On”
2Create a custom dimension in Google Analytics
- Log in to Google Analytics and go to “Account”
- Underneath “Property Settings”, choose “Custom Definitions” and “Custom Dimension”
- Create a new “Custom Dimension” and name it Optimizely, for example
- Set this to either Session or User level (we recommend User level, see why further down)
3 Add Custom HTML script in Google Tag Manager
- Log in to your GTM account
- Underneath “Tags”, click “New” and choose “Custom HTML Tag”
- Add the code available at the bottom of this post
- Choose “Fire on all pages” (this is the easiest way, but you can also choose to only fire on the pages where you’re conducting your experiment)
- Underneath “Variables”, create 4 Data Layer Variables (if you don’t have them already). They should be named eventCategory, eventAction, eventLabel. Just check the yellow box at the top for the last DLV.
- Create a new “Custom event” underneath “Triggers”. The “Event name” should match “event” and the Event Data Layer Variabel underneath filter should match “Event” optimizelyEvent (see image)
- Create a new Google Analytics tag underneath “Tags”
- Configure the tag and choose the variables you just created (as instructed in the images below)
- Important! Non-Interaction Hit needs to be set to True, otherwise you’ll mess up your bounce rate
- Your tag triggers on the event you created
- Double check everything, if it looks right, run Preview Mode and see how it looks.
4Create a Custom Report in GA
- Go back to Google Analytics
- Go to “Customisation”
- Create a new “Custom Report”
- Select your Optimizely Custom Dimension as the drill down dimension
- Configure the filters so that you only see current experiments
User or Session Scope in GA?
Our recommendation is to always look at the user level, but you can also configure settings to view the Session level, which is what Optimizely recommends…
What is the difference? You’ll want to choose the scope that matches the type of conversion you wish to track in your experiments. The User level scope is better if it’s possible for the user to leave the site to come back later and convert, without seeing the experiment again. However, please note that User data is only stored for three months before it disappears from GA.
Through Session scoping, you decrease the risk of overwriting existing data since a Custom Dimension in Google analytics only holds one value. On the other hand, we want to see users converting, not sessions. For more information, read Google’s documentation about Scoping.
If you choose to change the scope, be careful when re-using your Custom Dimension in GA. If you have the possibility, it’s good to have two different Custom Dimensions that you switch between. Also, to be consistent, make sure that your GA report has the same time span as your experiment.