google analytics content experiment without redirect getting no visitors

741 views Asked by At

I have implemented a GA experiment with no redirect

<script type="text/javascript">_udn = 'example.com'; _uhash='off';</script>
<script type="text/javascript" src="//www.google-analytics.com/cx/api.js?experiment=ExperimentID"></script>
<script type="text/javascript">var chosenVariation = cxApi.chooseVariation();</script>

<script type="text/javascript">

var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'AccountID']);
_gaq.push(['_setDomainName', 'example.com']);
_gaq.push(['_setAllowHash', false]);
_gaq.push(['_trackPageview']);

(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://' : 'http://') + 'stats.g.doubleclick.net/dc.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();

I don't seem to get any visits. The instructions I followed are here experiments-client-side

I have followed the accepted answer at this similar question

Google still does not seem to be receiving my experiment visits.

I am wondering if it has something to do with using stats.g.doubleclick.net/dc.js instead of ga.js

1

There are 1 answers

1
Leo On

Change the ga.src to ga.js experiments don't seem to work with stats.g.doubleclick.net/dc.js

ga.src = ('https:' == document.location.protocol ? 'https://' : 'http://') + 'stats.g.doubleclick.net/dc.js';

was changed to

ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';

This solution is not optimal since it stops me from getting demographic data but I am at least getting experiment data now.