A plugin for A/B split-testing HTML/CSS/DOM elements with javascript. WordPress, JQuery, and Google Analytics are required to run experiments.
Important: This plugin is probably best suited for developers with advanced JavaScript and theme development skills. It’s not overly complex, but if you’re not experienced with manipulating the DOM with JS, you probably won’t find this plugin useful.
ab.js filewp_optionsSupports both versions of Google Analytics, old “_gaq” and new Universal “ga()”
If you have Universal Analytics deployed on your site, you must provide a Custom Dimension key. Follow these instructions to setup a custom dimension. Then, eadd the dimension to the plugin settings.
Also, Universal Analytics users must use this (Custom Report)[https://www.google.com/analytics/web/template?uid=-O_F9EH4Qpil1mSt9l6U8A] to view test results (Universal Analytics only).
You can help to contribute to this project on github.com @ WordPress AB Testing
js/ab.js. This file is rewritten and updated often, so make sure you can update cached versions of this file.js/ab.js in your wordpress theme.js/ab.js file._setCustomVar() will not except all data._setCustomVar() is called just before firing _trackEvent() to store test data._gaq.push(['_setCustomVar', 'Slot', 'AB: ' + 'Test Name', 'Version Name', 2]); Slot = Test Index_gaq.push(['_trackEvent', 'AB Testing', 'Test View', 'Test Name & Version']);Supports both versions of Google Analytics, old “_gaq” and new Universal “ga()”
If you have Universal Analytics deployed on your site, you must provide a Custom Dimension key. Follow these instructions to setup a custom dimension. Then, eadd the dimension to the plugin settings.
Also, Universal Analytics users must use this (Custom Report)[https://www.google.com/analytics/web/template?uid=-O_F9EH4Qpil1mSt9l6U8A] to view test results (Universal Analytics only).
Here’s further reading about Google Analytics Custom Variables, Analytics Events, and Analytics Goals.
When a visitor views a page with a given test running, we use “Session Level” events to track the test view, because this ensures the test data will carry through the session to the conversion goal. From what I understand, “Page Level” custom variables will not work because we are firing an event after page load. Therefore, because the event is fired in the middle of a session, we must use session level custom variables Read More Here
After you have installed the plugin, in the wordpress admin, navigate to AB Testing and click Create New Test. Enter Test Name, each test Version’s Name, and enter your custom javascript in Version Code and click Save Test. Be sure to include your analytics=true flag in all of your test version code snippets.
The combination of Test Name and one Test Version Name must be less than 128 characters. This is because _setCustomVar limits character length.
Make sure your server /js/ directory and file /js/ab.js have permissions 0755 or 0775 so PHP can write output to the ab.js file.
When you are ready to start your test, click the checkbox Active, which will write your new test to the js/ab.js file and make your test live to your site visitors.
And don’t forget to update any cached versions of js/ab.js.
First, decide what elements in your theme HTML you want to test. Because your js/ab.js file is included globally into your theme, your A/B test code will manipulate any DOM elements that meet its conditions.
Therefore, do not run tests on general elements like <h1> or <button> unless you want to test these changes site wide. It is better to be highly specific and target your DOM elements with IDs and Classes.
Also, you must remember to include the analytics=true flag in your javascript code.
This is how we would test changing the color of <button class="test_button">Add To Cart</button> from green to orange. Let’s assume our button.test_button is already green in our current theme. Therefore, green is our control version.
However, since we don’t need to change the color for version 1, because it’s already green, we must still check to see if $('button.test_button') exists in the DOM, and if so, trigger the analytics=true flag to send our Custom Variable data to google analytics for the control version.
if ( $('button.test_button').length > 0 ) {
analytics = true;
}
In version 2 we are changing the color to orange. Once again, we must check if $('button.test_button') exists in the DOM. If it does, we change the button color to orange and trigger the analytics=true flag.
if ( $('button.test_button').length > 0 ) {
$('button.test_button').css('background-color', 'orange');
analytics = true;
}
analytics variable. It must be available to the ab.js file scope and set to true.analytics=true flag in your javascript code.You will find your test data located in Google Analytics Custom Variables Reporting.
Report Navigation: Audience -> Custom -> Custom Variables
You should not have more than 5 tests running at one time. Or more specifically, no more than 5 tests per visitor session, which is up to you to negotiate.
Depending on how many tests you have running at a given time, your tests will fall into 1 of 5 ‘slots’ in the Custom Variables Report, which are found at;
Custom Variable (Key 1) Custom Variable (Key 2) Custom Variable (Key 3) Custom Variable (Key 4) Custom Variable (Key 5)