pushtell / react-ab-test

A/B testing React components and debug tools. Isomorphic with a simple, universal interface. Well documented and lightweight. Tested in popular browsers and Node.js. Includes helpers for Mixpanel and Segment.com.
MIT License
752 stars 112 forks source link

GA Support? #1

Closed ratson closed 8 years ago

ratson commented 8 years ago

I see https://github.com/pushtell/react-ab-test/commit/fbd4c11e0f5b834caccca7fb047bb0c59c6fb035 moved GA related code to a branch.

Is there any limitations about GA for integration?

wehriam commented 8 years ago

There are no limitations on GA. That branch was formed around Content Experiments rather than core event tracking. It will eventually use the Content Experiments API to choose the version to display, and report directly into the Content Experiment results. Unfortunately that will require server side work that extends beyond this project's current scope.

To record events using analytics.js you could do something like:

emitter.addPlayListener(function(experimentName, variantName){
  ga('send', {
    hitType: 'event',
    eventCategory: experimentName,
    eventAction: 'play',
    eventLabel: variantName
   });
});

If you're tracking wins you might add:

emitter.addWinListener(function(experimentName, variantName){
  ga('send', {
    hitType: 'event',
    eventCategory: experimentName,
    eventAction: 'win',
    eventLabel: variantName
   });
});