Reputation: 11
My situation is... I load the api.js script <script src="//www.google-analytics.com/cx/api.js"></script>
always.
But then in my code, I want to decide if I do load the experiment depending on some conditions met by the users on my site...
For example, if they qualify for a promotion or sale, then load said experiment...
What this site gives away to me https://developers.google.com/analytics/devguides/collection/gajs/experiments#cxjs is that I can just load the api.js and then just do:
variationNumber = cxApi.getChosenVariation(‘experimentId’);
Whenever I feel like, and get a proper variation, so this user also starts participating in the experiment...
But every time I try to getChosenVariation I get -1... not even a 0.
So my question is, is it possible to load the API but request a variation afterwards based on some condition? Or am I forced to load the API specifying the experiment ID always?
Upvotes: 1
Views: 27