As of SimpleAB 1.1.0, integrating with Google Analytics is super easy. When a test is run, the
[[!+simpleab.ga_custom_var]] placeholder (as well as a more specific
[[!+simpleab.ga_custom_var.test_5]] placeholder where 5 is the ID of the test) is set, which you can throw in your code, like so:
_gaq.push(['_setCustomVar', 1, 'SAB-1','cta_v3', 2 ]);
This is what the values mean:
- _setCustomVar means it will assign the user a certain custom value, as defined in the rest of the properties
1 is the "index" where Google Analytics stores the data, in this case the data is assigned to custom var 1. This number is pretty arbitrary, and can be changed with the
simpleab.ga_custom_var_indexsetting if you have a good reason to do so.
SAB-1 obviously stands for SimpleAB test with ID 1. The prefix ("SAB") can be adjusted with the
- cta_v3 is, in this case, the name of the active variation. We strongly suggest not changing the variation name after starting the test.
2 is the "scope" for the custom variable. The possible values, defined with the
simpleab.ga_custom_var_scopesetting, are 1 (assign variable to user), 2 (assign variable to session) or 3 (assign variable to page).
For more information about custom variables, please see the official Google Analytics Documentation.
Please note that the custom variable will not be set when using the Admin Preview functionality.
Update variable template for new Google Analytics analytics.js code
In system settings, category "SimpleAB" create a new setting:
ga('set', '[[+name]]-[[+test]]', '[[+variation.name:htmlent]]');
Or whatever you need, based off the New Google Analytics Variables Documentation
Viewing test data in Google Analytics
To view the data in Google Analytics, browse to Audience > Custom > Custom Variables. The data will show up there. You can add secondary dimensions to get more insight into the users.