Basic A/B testing for WordPress.
A WordPress plugin to add A/B split tests without tracking individual users. Currently there are two kind of tests:
- Post title tests: test multiple headlines for a single post.
- DOM tests: test arbitrary changes to page content on DOM manipluations.
Depends on Advanced Custom Fields Pro plugin, which you will need to install and license separately.
This section describes how to install the plugin and get it working.
- Upload
split-tests/
to the/wp-content/plugins/
directory - Activate the plugin through the 'Plugins' menu in WordPress
split_tests_is_headless
- return true from a filter handler if you are using this plugin on headless WordPress (redirects get handled differently).split_tests_endpoint_url
- where JavaScript events should be sent (default is/wp-admin/admin-ajax.php?action=split_tests
).split_tests_current_url
- used to target on which pages tests will run (default is$_REQUEST['REQUEST_URI']
).split_tests_is_single
- whether a single post is being loaded (default is the result ofis_single()
only for thepost
post type).split_tests_post_variant
- used internally to modify a post.
This repo contains everything you need to get a test environment setup using the official WordPress docker image.
Developer dependencies
- node.js (tested on v20)
- nvm
- Docker Desktop
Build and start
./bin/build
./bin/start
Local website
Once you've built and started the docker containers, you can load up the website at localhost:8080. If you reload the page a couple times, you should see parts of the page change in response to two tests that are set up.
- DOM test: there are two variants for the about text "A commitment to innovation and sustainability" and "A commitment to maintenance and durability". If you click on the "About us" button, that will register as a conversion for a given variant.
- Post title: there are three variants for the Hello World post, if you scroll down to "Watch, Read, Listen" and reload you should see English, Spanish, and French versions of "Hello World." Clicking through to load the post will register as a conversion for that test.
WordPress admin credentials
Username: admin
Password: password
You can explore the example tests by clicking on Split Tests in the admin sidebar.
Yes, we count how many times a test is seen and how many times it converts, but we don't set/read cookies or otherwise attempt to track individual requests.
There are currently two kinds of conversions: page loads and clicks (on a specific configured element).
Yes, the tests will work fine with HTML generated behind a CDN, or using other kinds of front-end caching.
- Adds a
split_tests_is_headless
filter that changes how redirects are handled. - Bugfix: don't apply unpublished tests to the site.
- Bugfix: allow for zero title tests.
- Bugfix: undefined variable in title tests.
- Updates version of
@wordpress/scripts
to latest.
- Switch from REST API endpoints to
admin-ajax.php
. - Adds
split_tests_endpoint_url
andsplit_tests_current_url
filters (for headless). - Click conversions check up the DOM tree for a parent with an
href
attribute if one isn't found on the click event target. - Fixes a case-sensitivity bug (
DomTests
instead ofDOMTests
).
- Filter on
the_title
for post title tests - Add
split_tests_is_single
hook - Make JS more headless-friendly
Adds a cron mechanism to combine raw events in the database into daily aggregates
Context for where tests run ('all', 'home', or a 'url' pattern)
Split tests for DOM changes
Split tests for post titles