A/B testing on WordPress
Last updated: 29 November 2026.
You can A/B test a WordPress page with Pickbook A/B by adding 2 pieces of code: one in the header of every page, and one in a Custom HTML block on the page you test. There is no WordPress plugin and no visual editor, so you write the change to each version yourself, or you ask an AI agent to do it. Page caching works, because the version is chosen in the visitor's browser.
What you need
Pickbook A/B has no WordPress plugin and no visual editor, where you click on a page and change it. It is a script
that decides which version a visitor sees, and you show each version with a little code. If you want to edit
versions by pointing and clicking, a tool with a visual editor may suit you better. You need a place to add code to
the header of your site, which a theme setting or a plugin that adds code to the header gives you, and you need the
ability to add a Custom HTML block to a page. WordPress removes <script> tags from a Custom HTML block
when the person who saves the page lacks the unfiltered_html capability, for example a Contributor, so
save the page with an Administrator or Editor account. On a WordPress multisite network, only Super Admins have
the unfiltered_html capability, so save the page with a Super Admin account there.
Step 1: Add the script to the header
Add the script tag and the long line before it to every page's <head>. Use your theme's header
code setting, or a plugin that adds code to the header. Replace YOUR-ADDRESS and
YOUR-WEBSITE-KEY with the values from your Pickbook A/B dashboard.
<script>
// This line lets the code on the tested page run before pickbook.js has loaded.
window.pickbook=window.pickbook&&window.pickbook.choose?window.pickbook:function(p,q,f){p._q=q;p.ready=new Promise(function(r){p._ok=r});"choose goal flag identify reset consent".split(" ").forEach(function(m){p[m]=function(){var a=arguments;return p._r?p._r[m].apply(p._r,a):new Promise(function(r){p._off?r(f(m)):q.push([m,a,r])})}});p._e=function(){if(!p._r&&!p._off){p._off=1;p._ok(false);q.splice(0).forEach(function(c){c[2](f(c[0]))});document.documentElement.classList.remove("pickbook-hide")}};setTimeout(p._e,3000);return p}({},[],function(m){return m=="goal"||m=="flag"?false:null});
</script>
<script async src="https://YOUR-ADDRESS/pickbook.js?v=2" data-key="YOUR-WEBSITE-KEY" data-pickbook onerror="var c=document.documentElement.classList;c.remove('pickbook-hide');c.add('pickbook-ready');window.pickbook&&pickbook._e&&pickbook._e()"></script>
Step 2: Choose the version in a Custom HTML block
Add a Custom HTML block to the tested page, after the part it changes, and put the rest of the install code in it.
Replace the two comments with the code that shows each version, and use your test's own key in place of
shorter-signup.
<script>
// Put this in a Custom HTML block on the tested page, after the part it changes.
pickbook.choose("shorter-signup").then(function (version) {
if (version === "Version B") {
// Show Version B here.
} else {
// Show Original here.
}
});
// Run this line where the visitor reaches the goal, for example after they sign up:
// pickbook.goal("shorter-signup");
</script>
Call pickbook.goal("shorter-signup") where the visitor really reaches the goal, never when the page
loads. If the goal is on another page, such as a thank-you page, put the call in a Custom HTML block there. The
header code is already on that page.
Page caches and speed plugins
A page cache is fine, because the browser chooses the version after the page loads. If an optimization plugin delays,
combines, or moves scripts and the version shows late, exclude pickbook from those settings. If the first
version flashes before the right one appears, the install guide has a short anti-flicker snippet for the
<head>, and you add data-pickbook-hide to the part you test.
Check that it works
To see a version on purpose, open the page with ?pickbook_force=shorter-signup:Version%20B added to
the address. A forced version is never counted, so it does not change your results. Then start the test and watch
the visitor count in your dashboard. Your first test is free, one per website, and you don't need a card.
Let an AI agent do it
An AI agent can do the setup, the code, and the reading of the results for you, including the steps above. Read A/B testing with AI agents for how. The manual path in this guide still works if you prefer it.
Before you start
Enter your monthly visitors in What can I test with my traffic? to see which tests can finish within 60 days. If your site uses Plausible, Fathom, or Umami, read A/B testing with Plausible, A/B testing with Fathom, or A/B testing with Umami to send the version to it. If your site uses a consent banner, read Does A/B testing need cookie consent?.
To learn how the answer is worked out before you start, read How Pickbook A/B picks a winner. For plans and prices, see Pickbook A/B.
Questions
Is there a WordPress plugin for Pickbook A/B?
No. Pickbook A/B has no WordPress plugin. You add a script tag to your site's header and a small piece of code in a Custom HTML block on the page you test.
Does Pickbook A/B have a visual editor?
No. You change each version with your own code, or an AI agent writes it for you. If you want to edit versions by pointing and clicking, a tool with a visual editor may suit you better.
Does a page cache break an A/B test on WordPress?
No. A page cache is fine, because the version is chosen in the visitor's browser and not on your server. If a plugin that delays or combines scripts makes the version show late, exclude pickbook from its settings.
Can an AI agent set up the test on my WordPress site?
Yes. An AI agent can create the test, write the code, and read the results through Pickbook A/B's agent guide. You still need to let it add code to your site's header.
Sources
- Custom HTML, WordPress.org documentation, checked on 29 November 2026.
- Roles and Capabilities, WordPress.org documentation, checked on 29 November 2026.