In short
Testing a CTA (call to action) means comparing two versions of a button or link (wording, placement, shape, promise) with randomly split visitors, then keeping the one that produces the most conversions. The task produces a test log with, for each test, a hypothesis, a calculated sample size, a measured result and a decision. Once in place, CTA choices rest on how your visitors behave, not on the highest-ranking opinion in the room.
Why it matters
Button wording is often chosen in a meeting. “Request a quote”, “Get a call back”, “See pricing”: each has its arguments, and only visitor behavior settles the question. An A/B test (or split test) shows version A to half of the visitors and version B to the other half, and measures the difference in conversion under the same conditions, over the same period.
Two pitfalls make most tests useless. The first is statistical: on a low-traffic site, a difference of a few conversions is noise, and stopping the test as soon as one version “wins” produces false winners. The second is technical: a badly built test can look like cloaking, slow the page down or duplicate URLs. Google publishes precise rules for testing without risk to search rankings.
Testing does not replace the groundwork. It decides between reasonable options already built with make CTAs clearly identifiable (opens in a new tab).
What it improves
- Conversion rate Each winning test lastingly improves the tested page; a losing test prevents a bad change.
- Decisions A test log builds up knowledge of what works for your audience.
- Return on SEO and AI traffic Landing pages convert the same traffic better.
- Rankings No expected effect. A test that follows Google's recommendations is not penalized; a badly built test can disrupt indexing.
How to check
A sound testing program passes these checks:
- Each test has a written hypothesis, a primary metric and a sample size calculated before launch.
- Tests last at least two full weeks and are not stopped before reaching the planned sample.
- If the variants have distinct URLs, each carries a
rel="canonical"tag pointing to the original, and any redirect is temporary (302). - The test code is removed as soon as the test ends.
For a running test, check in a private window that the version shown stays the same from one page to the next (assignment cookie) and that the main content is identical for a bot and for a visitor.
How to implement
Before you start: do you have enough traffic?
The sample size depends on the current conversion rate and the difference you want to be able to detect. Formula for a two-sided test at 95% confidence and 80% power, in visitors per variant:
n = (1.96 + 0.84)² × (p1 × (1 − p1) + p2 × (1 − p2)) / (p2 − p1)²
| Current rate (p1) | Improvement to detect | Target rate (p2) | Visitors per variant |
|---|---|---|---|
| 2% | +20% | 2.4% | about 21,100 |
| 2% | +30% | 2.6% | about 9,800 |
| 4% | +20% | 4.8% | about 10,300 |
| 4% | +30% | 5.2% | about 4,800 |
| 8% | +20% | 9.6% | about 4,900 |
In Google Sheets, with p1 in B1 and p2 in B2:
=ROUNDUP((NORM.S.INV(0,975)+NORM.S.INV(0,8))^2*(B1*(1-B1)+B2*(1-B2))/(B2-B1)^2;0)
In French-language Excel: ARRONDI.SUP and LOI.NORMALE.STANDARD.INVERSE.N.
Divide by the number of visitors who see the page each week: if the test needs more than six to eight weeks, do not run it. Instead, test a bolder change, a placement seen by more visitors (a CTA present on a whole template), a more frequent metric (click on the CTA rather than a sale), or switch to user testing: five people completing a task in front of you reveal the major blockers.
Step 1 — Write the hypothesis
One row per test in the log:
| No. | Page or template | Observation | Hypothesis | Variant B | Primary metric | Sample per variant | Start | End | Result | Decision |
|---|---|---|---|---|---|---|---|---|---|---|
| 7 | Local service pages | 60% of visitors do not scroll down to the button (Clarity) | A CTA visible without scrolling increases inquiries | “Get a free quote within 24 h” button under the H1 | generate_lead rate per session |
4,800 | 03/11 | 01/12 | +18%, p = 0.03 | Roll out |
| 8 | Tea product page | Few clicks on “Add” | Showing the price per gram on the button reassures | “Add to cart · €12 per 100 g” | Add-to-cart rate | 9,800 | 10/11 | — | Running | — |
Fictitious values (dates in day/month format). Only one variable changes between A and B. The primary metric is chosen before the test; the others are secondary.
Step 2 — Follow Google's rules
Google Search Central sets four rules for tests:
- No cloaking: do not show Googlebot different content or URLs from those visitors see. Googlebot generally does not accept cookies: it sees the default version, which is normal.
- Canonical: if the variant has its own URL (
/devis-b/), it carries<link rel="canonical" href="https://example.com/devis/">. Google recommends the canonical rather thannoindexin this case. - Temporary redirect: redirect to the variant with a 302 (or in JavaScript), never a 301.
- Limited duration: stop the test as soon as it has reached a conclusion, publish the winning version and remove variants, scripts and tags.
For generative engines, a common-sense rule is added: test the form, not the facts. A price, a guarantee or a feature must not differ from one variant to the other, otherwise AI assistants' crawlers could pick up information that half the visitors do not see. See eliminate deceptive cloaking (opens in a new tab).
Step 3 — Choose the method
| Method | For whom | Points to watch |
|---|---|---|
| Browser-side testing tool (VWO, AB Tasty, Optimizely, Kameleoon) | Marketing teams without a developer | Script that can slow down rendering and cause flicker; consent required depending on the tool |
| Open source or feature flag tool (GrowthBook, PostHog) | Teams with a developer | Can be self-hosted, server-side assignment |
| Server-side or edge code (following sections) | Custom-built sites | No flicker, nothing to load in the browser; you maintain it yourself |
| CMS plugin | WordPress, Shopify | Traffic limits on free plans |
Google Optimize was shut down on September 30, 2023: old tutorials that use it are obsolete.
Step 4 — Measure in GA4
Send the experience_impression event when a visitor is assigned to a variant, with the exp_variant_string parameter in the TOOL-TEST-VARIANT format recommended by Google:
gtag('event', 'experience_impression', {
exp_variant_string: 'MAISON-cta-devis-B'
});
Register exp_variant_string as a custom dimension (Admin > Data display > Custom definitions, Event scope), then compare the variants in Explore > Free form: rows “exp_variant_string”, values “Active users” and “Key events” filtered on your conversion. Commercial tools generally send this event themselves.
Cloudflare
Versions Cloudflare Workers, all plans, November 2026.
A Worker assigns each visitor to a variant with a cookie and rewrites the button label on the fly, without changing the URL. Create it in Workers & Pages, then add a route on example.com/services/*:
export default {
async fetch(request) {
const cookie = request.headers.get('Cookie') || '';
let variant = cookie.match(/ab_cta=(A|B)/)?.[1];
const isNew = !variant;
if (isNew) {
variant = Math.random() < 0.5 ? 'A' : 'B';
}
let response = await fetch(request);
if (variant === 'B') {
response = new HTMLRewriter()
.on('[data-cta="devis"]', {
element(el) {
el.setInnerContent('Get a free quote within 24 h');
},
})
.on('body', {
element(el) {
el.setAttribute('data-ab-cta', 'B');
},
})
.transform(response);
}
response = new Response(response.body, response);
response.headers.append('Vary', 'Cookie');
if (isNew) {
response.headers.append('Set-Cookie', `ab_cta=${variant}; Path=/; Max-Age=2592000; SameSite=Lax; Secure`);
}
return response;
},
};
The button carries the data-cta="devis" attribute in your template. The analytics tag reads data-ab-cta on body (A by default) to send experience_impression. The text of variant B changes no facts; Googlebot, without a cookie, receives A or B at random, with the same main content.
Laravel
Versions Laravel 12 and 13.
A middleware assigns the variant and shares it with the views:
namespace App\Http\Middleware;
use Closure;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Cookie;
use Illuminate\Support\Facades\View;
use Symfony\Component\HttpFoundation\Response;
class AssignCtaVariant
{
public function handle(Request $request, Closure $next): Response
{
$variant = $request->cookie('ab_cta');
if (! in_array($variant, ['A', 'B'], true)) {
$variant = random_int(0, 1) === 0 ? 'A' : 'B';
Cookie::queue('ab_cta', $variant, 60 * 24 * 30);
}
View::share('ctaVariant', $variant);
return $next($request);
}
}
Register it in bootstrap/app.php for the routes concerned, then in the Blade view:
<a href="{{ route('quotes.create') }}" class="btn" data-ab-cta="{{ $ctaVariant }}">
{{ $ctaVariant === 'B' ? 'Get a free quote within 24 h' : 'Request a quote' }}
</a>
<script>
gtag('event', 'experience_impression', { exp_variant_string: 'MAISON-cta-devis-{{ $ctaVariant }}' });
</script>
Laravel Pennant, the official feature flag package, can also store the variant and display it with the @feature directive, drawing lots with Lottery::odds(). If a full-page cache is in place, it must vary by cookie.
Next.js
Versions Next.js 16 (App Router, proxy.ts file). On Next.js 15, the same code goes in middleware.ts with a middleware function.
// proxy.ts
import { NextResponse } from 'next/server';
import type { NextRequest } from 'next/server';
export function proxy(request: NextRequest) {
const current = request.cookies.get('ab_cta')?.value;
const variant = current === 'A' || current === 'B'
? current
: (Math.random() < 0.5 ? 'A' : 'B');
const headers = new Headers(request.headers);
headers.set('x-ab-cta', variant);
const response = NextResponse.next({ request: { headers } });
if (!current) {
response.cookies.set('ab_cta', variant, { path: '/', maxAge: 60 * 60 * 24 * 30, sameSite: 'lax' });
}
return response;
}
export const config = {
matcher: ['/services/:path*'],
};
// app/services/[slug]/page.tsx (excerpt)
import { headers } from 'next/headers';
const variant = (await headers()).get('x-ab-cta') ?? 'A';
const label = variant === 'B' ? 'Get a free quote within 24 h' : 'Request a quote';
Reading headers makes the page dynamic: the tested page is no longer served from the static cache during the test. On Vercel, the Flags SDK offers a documented alternative.
WordPress
Versions WordPress 6.4 and later, November 2026.
Nelio A/B Testing tests pages, posts, titles, menus, WooCommerce products, CSS and JavaScript, with conversion goals and a confidence report. Its free plan is limited to 500 tested page views per month, which is only enough for small tests. For a wording test, create an experiment on the page, edit the Button block in the variant, and choose as the goal a click on that button or a visit to the thank-you page.
Shopify
Versions Shopify stores, November 2026.
Since the Winter '26 Edition, Shopify has announced Rollouts, built into the admin, to schedule theme changes and A/B test them. Prepare the variant on a copy of the theme (button label changed in the editor), then compare it with the published theme; availability and exact settings are in the Shopify Help Center. Otherwise, use a testing app from the Shopify App Store, checking that it adds neither permanent redirects nor indexable URLs for the variants.
Step 5 — Read the result
Wait for the planned sample and at least two full weeks, then calculate significance. In Google Sheets, with conversions and visitors for A in B1 and C1, and for B in B2 and C2:
Rate A: =B1/C1
Rate B: =B2/C2
Pooled rate: =(B1+B2)/(C1+C2)
z: =(B2/C2-B1/C1)/SQRT(F1*(1-F1)*(1/C1+1/C2))
Two-sided p-value: =2*(1-NORM.S.DIST(ABS(G1);TRUE))
F1 holds the pooled rate and G1 the z value. In French-language Excel: RACINE, LOI.NORMALE.STANDARD.N(…;VRAI). A p-value below 0.05 indicates a difference that would be unlikely if it were due to chance. Above that, the test is inconclusive: keep A, or rerun with a more pronounced variant.
Then look at the secondary metrics (revenue, quality of inquiries) and the results by device, without reopening the decision on a subgroup found after the fact.
Warning: checking the results every day and stopping as soon as the p-value drops below 0.05 multiplies false winners. Set the duration in advance and stick to it.
Step 6 — Roll out and clean up
Publish the winning version in the template, remove the Worker, middleware, plugin or test script, delete the variant URLs by redirecting them to the original, and record the result in the log. A finished test that keeps running is exactly what Google asks you to avoid.
Common mistakes
- Launching a test without a sample calculation on a page that receives 300 visits a month: it will never reach a conclusion.
- Stopping at the first favorable difference: this is the main source of false winners.
- Changing several elements at once (wording, color, placement): if there is a gain, you do not know which one made the difference.
- Redirecting to the variant with a 301, or leaving variant URLs without a canonical.
- Testing different prices or facts: risk of misleading visitors, search engines and AI assistants.
- A test script that hides the page while it loads: the flicker and the rendering delay degrade LCP (Largest Contentful Paint).
- Forgetting consent: a tool that sets assignment or measurement cookies may be subject to it.
Frequently asked questions
Can an A/B test harm my search rankings?
No, if it follows Google's recommendations: the same content for Googlebot and for visitors, a canonical tag on variant URLs pointing to the original, temporary 302 redirects rather than 301s, and a duration limited to the time needed. A test that serves Googlebot, over the long term, a version visitors do not see may be interpreted as an attempt to deceive search engines.
How many visitors does a reliable A/B test need?
It depends on the conversion rate and the difference you are looking for. With a 4% rate and a 30% improvement to detect, you need about 4,800 visitors per variant at 95% confidence and 80% power; with a 2% rate and a 20% improvement, about 21,000. If the test lasts more than six to eight weeks, test a more pronounced change or a more frequent metric.
What can replace Google Optimize?
Google Optimize was shut down on September 30, 2023. Google lists integrations with AB Tasty, Optimizely and VWO, and publishes the experience_impression event to connect any tool to Google Analytics 4. Open source solutions such as GrowthBook or PostHog exist, and a simple wording test can also be coded on the server or in a Cloudflare Worker, with no additional script in the browser.
What should I test first on a call-to-action button?
Start with what changes the promise: the wording (“Request a quote” versus “Get a free quote within 24 h”) and the placement (visible without scrolling or not). These variables generally have more effect than color or shape. Start from a measured observation, for example a scroll map showing that the button is not seen, rather than from a preference.
Resources
- Google Search Central: Website testing and Google Searchdevelopers.google.com
- Google Analytics for developers: Integrate an A/B testing tooldevelopers.google.com
- Google Help: Google Optimize sunsetsupport.google.com
- Cloudflare Workers: A/B testing example and HTMLRewriterdevelopers.cloudflare.com
- Laravel: Pennantlaravel.com
- Next.js: proxy.tsnextjs.org
- Nelio A/B Testing on WordPress.orgwordpress.org
- Shopify Editions Winter '26: Rolloutsshopify.com
Updated on
Topic checklist (PDF)