Rich-text Reply

Google Analytics Integration

vaskazz 01-16-15
Accepted Solution

Google Analytics Integration

Hello,

 

I am trying to interate google analytics account with optimizely but the data is not showing in the google analytics.

 

What I have done:

1. I have turned on custom dimensions in google analytics (didn't put the code provided, because as I understood there is no need to do that if using OPTIMIZELY, not sure if understood correctly)

2. I have Turned on google analytics intgration in optimizely, and assigned to the experment that I am running, choosing the slot number from google analytics. 

 

3. I implemented optimizely code as following:

<...>

ga('create', 'UA-19581176-2', 'auto');

 

// Optimizely Universal Analytics Integration
window.optimizely = window.optimizely || [];
window.optimizely.push("activateUniversalAnalytics");

 

ga('require', 'linkid', 'linkid.js');

ga('require', 'displayfeatures');
ga('send', 'pageview');

<...>

 

The experiment is running fine, but can't get results to google analytics. Any suggestions?

 

 

Level 2

Brian_Abad 01-16-15
 

Re: Google Analytics Integration

Hey @vaskazz ,

 

Have you entered the Universal Analytics tracking code to your page? Here's a template of how that would look:

 

<html>
  <head>
    <script src="//cdn.optimizely.com/js/XXXXXXX.js"></script> 
  </head>
  <body>
    ...
    <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','//www.google-analytics.com/analytics.js','ga');
      
      ga('create', 'UA-40337519-1', 'www.mysite.com');      

      // Optimizely Universal Analytics Integration code
      window.optimizely = window.optimizely || [];
      window.optimizely.push(['activateUniversalAnalytics']);
      
      ga('send', 'pageview');
    </script>
  </body>
</html>

 Please note the following order:

 

Optimizely Snippet --> UA Tracking Code --> GA 'create' call --> Optimizely API call --> GA 'pageview' call

 

It is of utmost importance for this order to be followed for this integration to work. The reason being is that Optimizely fires first to define that a user has been in an experiment, the GA object is defined, Optimizely pushes the experiment and variation name to the GA object, and that information is sent off to GA as part of the 'pageview' tracking call. 

 

This is covered in complete detail here: https://help.optimizely.com/hc/en-us/articles/200039995-Integrating-Optimizely-with-Google-Analytics...

 

Could you confirm for me whether you have the UA tracking code present in your page in the appropriate order? Happy to help further if needed!

---
Brian Abad
Manager, Technical Support
Customer Success
Optimizely
vaskazz 01-16-15
 

Re: Google Analytics Integration

@Brian_Abad

Yes I implemented it. It looks as following:

&lt;script src="//cdn.optimizely.com/js/xxxxxxx.js">&lt;/script&gt;

&lt;script&gt;
(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','//www.google-analytics.com/analytics.js','ga');

ga('create', 'UA-xxxxxxxx-x', 'auto');

// Optimizely Universal Analytics Integration
window.optimizely = window.optimizely || [];
window.optimizely.push("activateUniversalAnalytics");

ga('require', 'linkid', 'linkid.js');
ga('require', 'displayfeatures');
ga('send', 'pageview');

&lt;/script&gt;

still can't get it to work? Any suggestions?
Level 2
greg 01-20-15
 

Re: Google Analytics Integration

Have you verified that the slot numbers match? Silly question, maybe, but some times it's the small things that break everything...
Level 2
vaskazz 01-20-15
 

Re: Google Analytics Integration

In google analytics under Custom dimension name there INDEX 1 is set. In the Optimizely the custom variable slot is set to 1 also. I believe this is the place You are talking about, but still doesnt work. I don't know what to do, seems that I set everything correct.

Level 2
greg 01-20-15
 

Re: Google Analytics Integration

The next thing I would do is confirm whether Optimizely is properly sending dimension data.

You can download the Google Analytics Debugger extension for chrome, then open the javascript console window (ctrl+shift+j on Windows), and load your page with the experiment. You should see in the console window that a page view was sent to GA with (or without) custom dimensions set.

If they're not set, then at least you know the problem is with Optimizely.
Level 2
vaskazz 01-20-15
 

Re: Google Analytics Integration

I tried analytics debugger, I can't see any custom dimension set there. I believe thats the problem. What I might have done wrong?

Level 2
Brian_Abad 01-20-15
 

Re: Google Analytics Integration

Could you provide us the URL where this is occurring? Perhaps I can see on my end what's going on to see if we can provide a more concrete solution!
---
Brian Abad
Manager, Technical Support
Customer Success
Optimizely
vaskazz 01-20-15
 

Re: Google Analytics Integration

Brian_Abad 01-20-15
 

Re: Google Analytics Integration

I couldn't find any active experiments on that page. Could you check your URL Targeting, Audience visitor conditions, and Traffic Allocation to see if there are any limitations on what visitors can get bucketed into this experiment?

In order for the custom dimension to be set and sent to GA, there must be an active experiment on the page.

A few others things worth of checking:

* Whether the integration is turned on within the visual editor (Options --> Integrations)
* Creating the proper Custom Report (https://help.optimizely.com/hc/en-us/articles/200039995-Integrating-Optimizely-with-Google-Analytics...
* Check whether there is a running experiment on the page (https://learn.optimizely.com/hc/en-us/articles/201943813#audiences_goals)

Please let us know how this works for you!
---
Brian Abad
Manager, Technical Support
Customer Success
Optimizely
vaskazz 01-20-15
 

Re: Google Analytics Integration

Could You please look if You could see any active experiments on this page:
http://www.sportguru.lt/trx

 

The thing is that I can see results in Optimizely experiment, but now in google analytics.

Level 2
Brian_Abad 01-20-15
 

Re: Google Analytics Integration

So what seems to be the issue is that the experiment has the Classic Google Analytics integration turned on as opposed to Universal Analytics.

Classic GA = custom variable slots
Universal GA = custom dimensions

The code I've provided and that is present on the page is for Universal GA, but the integration that is turned on is for Classic GA. Here's the article that outlines how to turn on Universal GA within your experiment: https://help.optimizely.com/hc/en-us/articles/200039995-Integrating-Optimizely-with-Google-Analytics...

It may also be helpful to read the segment regarding setting up the custom dimension and custom report that is part of the same article.

Let us know if you have further questions!
---
Brian Abad
Manager, Technical Support
Customer Success
Optimizely
vaskazz 01-21-15
 

Re: Google Analytics Integration

That worked, Thanks a lot, I didn't even realized that it could be called just as UNIVERSAL ANALYTICS tools.

Thanks again.

Level 2