I'm running a google analytics experiment, and I'm only getting sessions for one variant.
- The original page redirects to the variant page when testing.
- "Distribute sessions evenly" option is set to on.
- Both pages validate in the google experiment admin
- Experiment code is immediately after the opening
<head>
tag, on original page only. Variant page only has the normal GA tracking code. - GA script tag and
ga.create
is right before closing</head>
tag on both pages ga.send('pageview')
is right before closing</body>
tag, as well as some js code to send events to GA when user clicks links.
186 sessions on the experiment, and 186 sessions on original page only. No sessions on the variant page.
Also, when I'm redirected to the variant page, I get the plain url without any UTM codes in the querystring.
I'll post the HTML if needed.
...
Here's the original page HTML. Variation page is the same, except without the Content Experiment code, just the analytics tag. I do get events record in analytics from the variation page, just not in the experiment:
<html><head>
<!-- Google Analytics Content Experiment code -->
<script>function utmx_section(){}function utmx(){}(function(){var
k='###',d=document,l=d.location,c=d.cookie;
if(l.search.indexOf('utm_expid='+k)>0)return;
function f(n){if(c){var i=c.indexOf(n+'=');if(i>-1){var j=c.
indexOf(';',i);return escape(c.substring(i+n.length+1,j<0?c.
length:j))}}}var x=f('__utmx'),xx=f('__utmxx'),h=l.hash;d.write(
'<sc'+'ript src="'+'http'+(l.protocol=='https:'?'s://ssl':
'://www')+'.google-analytics.com/ga_exp.js?'+'utmxkey='+k+
'&utmx='+(x?x:'')+'&utmxx='+(xx?xx:'')+'&utmxtime='+new Date().
valueOf()+(h?'&utmxhash='+escape(h.substr(1)):'')+
'" type="text/javascript" charset="utf-8"><\/sc'+'ript>')})();
</script><script>utmx('url','A/B');</script>
<!-- End of Google Analytics Content Experiment code -->
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
...
<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', '###', 'auto');
</script>
<script
src="http://code.jquery.com/jquery-3.2.1.min.js"
integrity="sha256-hwg4gsxgFZhOsEEamdOYGBf13FyQuiTwlAQgxVSNgt4="
crossorigin="anonymous"></script>
</head>
<body>
...
<script type="text/javascript">
ga('send', 'pageview');
$('a.red_button').click(function(e) {
ga('send', 'event', 'Click', 'red_button', 'conversion');
});
</script>
</body></html>