GA - Experiments does not work

1.6k views Asked by At

we try to set up experiments in our site. We would like to testing 3 type of banner on our home page. 1. If anybody click on the banner, makes event, which si set up as a goal in GA. This goal measure clicking correctly. 2. We implement code for measuring experiments and made javascript function for changing banners, they changing well. 3. For set up whole experiments in GA and in code we follow this documentation: https://developers.google.com/analytics/solutions/experiments-client-side

Finnaly our whole GA script on site looks this:

<script src="//www.google-analytics.com/cx/api.js?experiment=sTe5dJkJTfmSO8YXsc7Kuw">

<script>
    var variation = cxApi.chooseVariation();
    cxApi.setChosenVariation(variation);
</script>
<script type="text/javascript">
    var _gaq = _gaq || [];
    (function() {
        var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
        ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
        var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
    })();
</script>
<script type="text/javascript" src="http://oursite.cz/js/ga.js"></script>
<script type="text/javascript">
    _gaq.push(['_trackPageview']);
</script>

Problem is, that experiment does not work. It does not measure anything. When we try to look on console, what data are sending, we realize, that ` correctly send hash Te5dJkJTfmSO8YXsc7Kuw, but that is all, There is no data of variation type, which was choosed by

<script>
        var variation = cxApi.chooseVariation();
        cxApi.setChosenVariation(variation);
    </script>

It should sent 0 or 1 or 2, but it send nothing. What we make wrong? Thank you for answer,

1

There are 1 answers

1
Blexy On

You're missing the closing tag when loading the content experiment.

You have:

<script src="//www.google-analytics.com/cx/api.js?experiment=sTe5dJkJTfmSO8YXsc7Kuw">

Should be:

<script src="//www.google-analytics.com/cx/api.js?experiment=sTe5dJkJTfmSO8YXsc7Kuw"></script>