Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Multiple experiments with google analytics api

We use the analytics api to download the experiments and variations, and do the variation selection for our visitors on our end (i.e. Server-side experiments as described here: https://developers.google.com/analytics/solutions/experiments-server-side)

When a visitor visits a url that is under experimentation and they have a selected variation, they get the javascript as described like:

<script>
cxApi.setChosenVariation(1, 'a9BcDEFgHijKl8mON-Opqw');
</script>

This is working fine. We would like to have multiple experiments running(For example, a site-wide experiment involving the menu, and a page-specific experiment), the variation selection and everything works fine on our end. To the user, when they are part of multiple experiments, they get multiple calls of setChosenVariation like so:

<script>
cxApi.setChosenVariation(1, 'a1BcDEFgHijKl2mON-3pqr');
cxApi.setChosenVariation(1, 'z9YxWVVuTsrPl8oNM-7lkj');
</script>

I can't find any reason why this shouldn't work, but in the results from the experiments, when this happens, we see all the users being assigned only to one experiment, though both experiments have results (creating conversion rates of >100%).

conversion rate > 100%

Is there an explanation of this behaviour (I feel like perhaps the second call is overriding the first call?) and/or a correct way to do this?

Thanks very much

like image 979
bencoder Avatar asked Jul 16 '14 09:07

bencoder


People also ask

Does Google Analytics use API?

The Google Analytics Reporting API v4 provides programmatic methods to access report data in Google Analytics (Universal Analytics properties only). With the Google Analytics Reporting API, you can: Build custom dashboards to display Google Analytics data.

Does Google optimize collect data?

Optimize data is pulled from the underlying Google Analytics data tables, and is not sampled. And, Optimize does not impose any sampling in the Optimize interface. This means that any data you see in Optimize is unsampled, regardless of whether you utilize Optimize or Optimize 360, or Analytics or Analytics 360.

Is Google optimize free?

Being a paid version, it has all the features of Google Optimize plus many of the features the free version lacks. Google Optimize is a tool for getting started on conversion rate optimization and testing, and it's good for smaller enterprises with less budget and website traffic.


1 Answers

Ease answer didn't work for me. Thanks to Google Analytics Debugger extension I could see that both those ga('send','pageview') were sending data about second experiment. Using synchronous call worked and I ended up with something like:

var sendExperiment = function(tracker, experimentVar, experimentId) {
  cxApi.setChosenVariation(experimentVar, experimentId);
  tracker.send('event', 'experiment', 'view',{'nonInteraction': 1});
}

ga(function(tracker) {
 sendExperiment(tracker, 1, 'a1BcDEFgHijKl2mON-3pqr');
 sendExperiment(tracker, 2, 'z9YxWVVuTsrPl8oNM-7lkj');
});
like image 191
basiam Avatar answered Oct 14 '22 19:10

basiam