Rich-text Reply

Integration of Google Analytics to Manual Activation Experiments

chellaifajardo 04-01-16

Integration of Google Analytics to Manual Activation Experiments

Hi,

 

We have a feature on our site where we force a user to be in a specific experiment and variation, for this we use the bucket visitor and activate feature of optimizely. However, I can't seem to make it work for integration in Google Analytics (UA).

 

It didn't push any data to the custom dimension I set to the experiment.

 

var forced_experiment_id = 12345;
var variant_id = 123445;
window
['optimizely'].push("activateUniversalAnalytics");
window['optimizely'].push(["bucketVisitor", forced_experiment_id, variant_id]);
window['optimizely'].push(["activate", forced_experiment_id, variant_id]);
ga('send', 'pageview'); 

 

Am I doing the right thing?

Thanks! 

David_Orr 04-04-16
 

Re: Integration of Google Analytics to Manual Activation Experiments

Hi,

 

Thank you for providing the code.  There may be a possibility that the timing of the code is the issue. In order to trigger a pageview for a manually activated experiment the ga('create'.. will need to activate before the manually activated experiment. 

 

If you are trying to push the experiment info from the one that is forced,

var forced_experiment_id = 12345;

 

then the ga pageview call will have to be in the "Experiment Javascript" options. The reason is because the pageview goal may fire faster than the experiment activates. 

 

I recommend utilizing GA's non-interaction option instead of sending a page view. If the page already has a pageview, the additional pageview triggered within Optimizely may artificially decrease the bounce rate. Here's a link to Google's article for more info on how to trigger a non-interaction event:

 

https://developers.google.com/analytics/devguides/collection/analyticsjs/events#non-interaction_even...

 

I also recommend debugging by using Google's GA Debugger Chrome extension: 

 

https://chrome.google.com/webstore/detail/google-analytics-debugger/jnkmfdileelhofjcijamephohjechhna...

 

David

Senior Technical Support Engineer
Optimizely

Re: Integration of Google Analytics to Manual Activation Experiments

Hi,

 

Can you look at my sample page?

<html>
<head>
<script>
window.optimizely = window.optimizely || [];
window.optimizely.push(["bucketVisitor", 5450121303, 5437493321]);
window.optimizely.push(["activate"]);
window.optimizely.push("activateUniversalAnalytics");
</script>
<script src="https://cdn.optimizely.com/js/5296620053.js"></script>
<!-- Google Analytics -->
<script>
(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','https://www.google-analytics.com/analytics.js','ga');

ga('create', 'UA-237232-1', 'auto');
ga('send', 'pageview');
</script>
<!-- End Google Analytics -->
</head>
<body>
<div class="title">
<h1>Hello World</h1>
</div>
</body>
</html>

 

What do you think is the issue? It's not working too.

Thanks. 

Re: Integration of Google Analytics to Manual Activation Experiments

You can access the page here:

http://qa.printrunner.com/test.html