splitrb / split-analytics

:bar_chart: An extension to Split to push test data to Google Analytics.
http://libraries.io/rubygems/split-analytics
MIT License
50 stars 14 forks source link

When there are more than 5 experiments the index used for the script is messed up. #35

Open andrehjr opened 5 years ago

andrehjr commented 5 years ago

The index on _setCustomVar cannot be greater than 5, see: https://developers.google.com/analytics/devguides/collection/gajs/gaTrackingCustomVariables

            <script type="text/javascript">
          var _gaq = _gaq || [];
          _gaq.push(["_setAccount", "UA-11223344-1"]);

          _gaq.push(["_setCustomVar", 4, "ab_test_four", "c", 1]);
_gaq.push(["_setCustomVar", 5, "ab_test_five", "a", 1]);
_gaq.push(["_setCustomVar", 6, "ab_test_six", "b", 1]);
_gaq.push(["_setCustomVar", 7, "button_color_on_signup", "green", 1]);
_gaq.push(["_setCustomVar", 8, "button_color_on_login", "green", 1]);
          _gaq.push(["_trackPageview"]);
          (function() {
            var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
            ga.src = ('https:' == document.location.protocol ? 'https://ssl.google-analytics.com/ga.js' : 'http://www.google-analytics.com/ga.js');
            var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
          })();