Google analytics experiment missing data

351 views Asked by At

So I implemented server-side experiment on google analytics. On my page, I send info on which variation is chosen (server is choosing which version it is currently showing, 50/50)

(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-SITE ID-ID', 'auto');

ga('set', 'expId', '<?php echo $experimentId; ?>');     
ga('set', 'expVar', '<?php echo $chosenVariation; ?>'); 

ga('send', 'pageview');

For some reason, experiment shows very few sessions when compared to what Behaviour flow is showing. For example, under Behaviour->Site Content I get 200 unique pageviews today, yet on my experiment page it says that I have only 10 experiment sessions. Am I missing something in my implementation? Why the difference is so big?

Thank you!

1

There are 1 answers

0
Tob On

First off:

  1. getElementsByTagName(o) [0]; remove the space
  2. new Date(); correct that as well

Check if the __utmx and __utmxx cookies are being set correctly.

It might be that either $experimentId or $chosenVariation are somehow faulty.

Are you including any specific experiment code? (cxApi or the experiment code snippet provided by the Google Analytics web interface)