Rich-text Reply

Using Google Analytics And Optimizely

TeamFYZ 02-08-15

Using Google Analytics And Optimizely



I have two questions regarding Google Analytics and Optimiezly :


First one is easy. I think I am using Universal Tracking but I'm not sure can you confirm this ?








The analytics.js JavaScript library is built on Universal Analytics technology. If you’re using a tracking code snippet on your website that references analytics.js, you’re using Universal Analytics.


source :"


And I have analytics.js so I'm using Universal Analytics ?




My second question is that I can't make sens of the data in my picture below. I started running an experiment on Optimizely and I saw this in GA (I didn't integrate with it) can you tell me what's going on and if I integrate Optimizely and GA my data will be more clear?


The path is : Behavior > Site Content > Landing Pages




See ?  I have more people visiting my website it would be impossible to have insights as each visitor is on a different landing page. I hope I explained my problem well if you have any questions don't hesitate.


Thanks a lot for your help Smiley Happy

Level 2

Amanda 02-08-15

Re: Using Google Analytics And Optimizely

Yes, that's UA. You are correct. 


Also, if you integrate Optimizely with your UA account, then you will be able to see the data clearly split into the variations vs the original. See the screenshot below as an exmaple. 


UA report.png


You can find the details on how to set this up in our article here:


Let us know if you have any questions! 

TeamFYZ 02-08-15

Re: Using Google Analytics And Optimizely

[ Edited ]

I'm not sure If I Implemented well Optimizely with GA can you tell me if I missed something ?


1. I enabled in the Integration Tab of Optimizely the Google Universal Analytics

2. I went to my website I copied the tracking code which you can see here : 





It finishes with : 

window.optimizely = window.optimizely || [];
window.optimizely.push("activateUniversalAnalytics");ga("send", "pageview");


3. I created my dimension in GA but I didn't change the values in the right box under "Examples Codes for This Dimension" and I wonder if I made a mistake here ?





4. As the index of my dimension is number 1 I directly saved from here : 




I didn't understand this part of the tutorial hope I missed nothing that could make my integration not work : 



"By enabling this integration, you actually replace the need to include the UA setDimension code on your page. If you include the ga('set', 'dimension1', dimensionValue); code on your site, you may actually end up overwriting the Optimizely/UA integration."  


AND the point 4 of the tutorial : 


Specify a "custom tracker" if you are using a custom event tracker other than the default. This will change Optimizely's integration call to use the custom tracker rather than the default. For example, if your website is using the call:

  1. ga('tracker2.send', 'pageview');
    then you would enter tracker2 into the Specify a custom tracker field, and Optimizely would integrate with tracker2 instead of the default tracker.


5Configured my custom report in GA : 




The filters use a Regex match on the experiment ID for the experiment which I found here : 





By the way I use a drupal website.


I hope I'm as  clear as I can possibly be if you have any questions let me know. I really want to get this one right (which justify my detailed posts Smiley Wink


If someone can tell me if I did something wrong or missed a step in my configuration I'd be really grateful. T


hank you! 




Level 2
Brian_Abad 02-10-15

Re: Using Google Analytics And Optimizely

Thanks for all the details, @TeamFYZ !


The key for the Optimizely <> Universal Analytics integration is the order in which the code is executed on the page. Here is an example template for how it should look:


    <script src="//"></script> 
    <script type="text/javascript">
      // Universal Analytics Setup
      (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){ (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o), m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m) })(window,document,'script','//','ga');
      ga('create', 'UA-40337519-1', '');      

      // Optimizely Universal Analytics Integration code
      window.optimizely = window.optimizely || [];
      ga('send', 'pageview');

 Please note the important ordering as:


  • Optimizely snippet --> GA tracking code --> Optimizely API Call (activateUniversalAnalytics) --> GA 'pageview' call

As long as this is fired in order then you should be set to go!


Regarding the other questions:

  • A custom tracker is only needed if, say for instance the GA 'pageview' call looks like: 
    ga('tracker2.send', 'pageview');

     In this scenario, 'tracker2' is the custom tracker that you would need to input within the Optimizely editor set-up. Based on the code you've provided this is not needed for this experiment. 

  • Setting a dimension is not a needed part and just a warning in this case. 

If you'd like I can do a double-check if you can provide me the URL in which the experiment is running.

Brian Abad
Manager, Technical Support
Customer Success
TeamFYZ 02-13-15

Re: Using Google Analytics And Optimizely

OK nice if you can check on my website if all works great it would be awesome. Here's the JS from my website the order seems right :




There's only this blue part I hovered with my mouse that you don't have.




The problem I try to avoid is that I have super targeted leads that I analyze and my website aims to a really specific market. In my GA I had this before :




And this doesn't make sense. And that's what I try to avoid and I hope by integrating with GA it will work right ?


So if someone comes to my website from let's say the country I am it won't show that they came from USA cause they went to optimizely's server first ?


I want to be sure that If someone visits from my country GA shows it right. If you can answer these questions I think I'm all set to go experiment Smiley Happy

Level 2
Brian_Abad 02-13-15

Re: Using Google Analytics And Optimizely

Thanks for the follow-up!


The Optimizely <> GA integration simply passes the experiment and variation name to a custom dimension you deisgnate. From there, this allows for easier segmentation within GA for associated data of visitors who were bucketed into an experiment.


Optimizely does not affect data other than adding what you can think of as a flag to the visitor to indicate they are in an experiment. So no worries regarding your traffic getting re-classified! Smiley Happy


You will also want to create a custom dimension and a custom report as outlined in our knowledge base:


If you want to provide the URL to your experiment I can double check the integration for you.



Brian Abad
Manager, Technical Support
Customer Success