How to A/B Test a Landing Page: A Step-by-Step Guide
How do you set up a landing page A/B test? Hypothesis, sample size, server-side splitting, SEO rules and GA4 measurement for a test you can actually trust.
A landing page A/B test is a controlled experiment in which you randomly split traffic between two versions of your landing page and measure which one brings more conversions. A well-run test ends the “I think this headline is better” debate with data. In this post I walk through a landing page test step by step, from the hypothesis and sample size to server-side setup, SEO and GA4 measurement.
I started as a software developer and moved into performance marketing, so I look at A/B testing from two sides. The marketing side asks “what should we test?” The engineering side asks “can we trust the result?” This post leans on the second question, because that is where most tests are lost. For the broader picture, see the post on marketing engineering.
How do you A/B test a landing page?
Short answer
How do you A/B test a landing page?
You A/B test a landing page by randomly splitting traffic between the current version of the page and a new version that contains one change. First you set the primary metric and the hypothesis, then you calculate how many visitors you need. The test runs until it reaches that number, and only then do you read the result.
- Choose the page to test and a single primary metric.
- Write a measurable hypothesis based on observation.
- Calculate the sample size and test duration in advance.
- Build a variant that changes only one thing.
- Split traffic randomly and pin each user to their variant.
- Send the variant information to your analytics tool.
- Read the result once the planned sample is reached and ship the winner.
The order of these seven steps matters. A test that starts without a sample size calculation is a test that does not know when it will end. Such a test usually gets stopped the moment the chart “looks good.” That sharply increases the chance of picking the wrong winner.
When I choose a page to test, I look at two criteria: enough traffic and business weight. A campaign page that receives most of your paid traffic is a better candidate than a subpage with a few hundred visits a year. I recommend reading how to create a landing page first for the basic structure. Running an A/B test on a poorly built page means looking for a precise answer to the wrong question.
What is the difference between an A/B test, a split URL test and a multivariate test?
A/B tests, split URL tests and multivariate tests are three types of experiment that serve the same goal with different methods. In an A/B test, one element changes on the same URL. In a split URL test (split test), each version lives at its own address and traffic is split between the addresses. A multivariate test tries combinations of several elements at the same time.
Google’s definition makes the same distinction. According to Google, an A/B test tries two or more variations of a change. A multivariate test tests more than one type of change at once, looking for the impact of each change and the interactions between them.[1]
A/B or split URL test
- One variable or one page version is compared
- Produces results with moderate traffic
- The result is simple to read: which one won?
- Suits layout, template and flow changes
Multivariate test
- Every combination of several elements is tried
- Required traffic multiplies as combinations grow
- Also shows interactions between elements
- Suits fine-tuning on high-traffic pages
In practice I use split URL tests for most landing page tests. The reason is technical: a new headline, a different form structure or reordered sections usually need a separate template. Changing all of that with JavaScript after the page has loaded is both fragile and slow.
How do you choose a hypothesis and a primary metric?
A good A/B test hypothesis is a sentence that is based on an observation, describes one change and says which metric will move and how. “The new design will be better” is not a hypothesis. “Session recordings show the form sits below the fold on mobile. If we move the form to the first screen, the mobile form submission rate will increase” is a hypothesis.
The hypothesis should come from data, not from a guess. Heatmaps, session recordings, field-level form abandonment and the search terms report are good starting points. On the ad side, a mismatch between the query a user searched and the page headline is a common problem. That match also affects landing page experience, one of the components of Google Ads Quality Score.
The primary metric is the single measure that decides the winner, and it is written down before the test starts. Switching metrics after the test with “form submissions didn’t change, but phone clicks went up” is the shortest route to reporting a chance difference as a win. You can track secondary metrics too, but the decision is made on the primary metric.
How much traffic do you need for an A/B test?
The traffic an A/B test needs is calculated from the current conversion rate and the smallest difference you want to detect. That smallest difference is called the minimum detectable effect (MDE). The smaller the difference, the more visitors you need to separate it from noise.
A commonly used approximation for 95 percent confidence and 80 percent statistical power is:
visitors per variant ≈ 16 × p × (1 − p) / δ²
p = current conversion rate (e.g. 0.04)
δ = absolute difference you want to detect (e.g. 0.01 → from 4% to 5%)
I ran a few example calculations with this formula. The numbers in the table are not industry averages; they are only the output of the formula:
| Current conversion rate | Difference to detect | Visitors per variant |
|---|---|---|
| 4% | 1 point (4% → 5%) | ≈ 6,100 |
| 4% | 2 points (4% → 6%) | ≈ 1,500 |
| 10% | 2 points (10% → 12%) | ≈ 3,600 |
The table shows something important: when you halve the difference you want to detect, the required traffic quadruples. That is why testing small improvements on a low-traffic page is not practical. On such pages it makes more sense to test large, bold changes.
When do you stop a test?
You stop a test when the planned sample is reached and at least one or two full weeks have passed. The full-week rule keeps weekday and weekend differences in behavior from distorting the result. Checking results every day and stopping as soon as you see significance (peeking) raises the false positive rate.
Google is also clear about test duration. According to Google, a test should run only as long as necessary, and alternate URLs and test code should be removed as soon as possible after it ends. An experiment that runs for an unnecessarily long time may be interpreted as an attempt to deceive search engines.[1]
How do you spot a sample ratio mismatch?
A sample ratio mismatch (SRM) is a clear deviation between the number of users assigned to each variant and the planned split ratio. If one variant consistently gets noticeably more users in a test split 50 / 50, the problem is in the setup, not the design. Visits lost during the redirect, bot traffic or a measurement tag that does not fire on one variant are the typical causes. I do not interpret the result of a test with SRM; I fix the setup first and restart the test.
Client-side or server-side A/B testing?
Server-side A/B testing is the method in which the variant is chosen at the server or edge layer before the page is sent to the browser. In client-side testing, the page first loads with the control version and then JavaScript changes the content. For landing page tests I prefer the server-side method.
The best-known problem with client-side tests is flicker. The user sees the original headline for a moment, and then the headline changes. This both undermines trust and contaminates the result, because variant B is really tested as “B plus flicker.” Anti-flicker snippets that keep the page blank for a while to hide the flicker, in turn, slow down loading.
Layout shift also happens when the page changes after loading. According to Google’s web.dev documentation, a Cumulative Layout Shift (CLS) value of 0.1 or less is needed for a good user experience.[5] A late-loading test script can easily push you past that limit. I explain why page speed matters in detail in the post on improving Core Web Vitals.
A simple split URL setup at the edge
The example below shows the logic of splitting traffic between two URLs with a function that handles requests at the edge. On the first visit, the user is randomly assigned to a variant, and that choice is pinned with a cookie. That way the same user sees the same version on every visit.
// Simple split URL test: sends /offer/ requests to the control (A) or variant (B) page
export default {
async fetch(request) {
const url = new URL(request.url);
if (url.pathname !== '/offer/') return fetch(request);
const cookie = request.headers.get('Cookie') || '';
let variant = (cookie.match(/ab_offer=(a|b)/) || [])[1];
if (!variant) variant = Math.random() < 0.5 ? 'a' : 'b';
if (variant === 'a') {
const res = await fetch(request);
const out = new Response(res.body, res);
out.headers.append('Set-Cookie', `ab_offer=a; Path=/; Max-Age=2592000; SameSite=Lax`);
return out;
}
// Variant B: a temporary (302) redirect, not a permanent one
const target = new URL('/offer-b/' + url.search, url);
return new Response(null, {
status: 302,
headers: {
Location: target.toString(),
'Set-Cookie': `ab_offer=b; Path=/; Max-Age=2592000; SameSite=Lax`,
},
});
},
};
There are three things I pay attention to in this setup. First, I keep the query parameters (gclid, UTM) during the redirect; otherwise ad attribution breaks. Second, the redirect uses the 302 status code. Third, the variant page has a canonical tag pointing to the original URL. The reason for the last two points is in the next section.
Landing page tests with Google Ads experiments
Another option for ad traffic is Google Ads custom experiments. According to Google, the experiment arm runs on the original campaign and splits the budget between the control and experiment arms. In Search campaigns, the experiment can be split into cookie-based or search-based groups.[4] By changing only the final URL in the experiment arm, you can compare two landing pages under the same campaign conditions.
The advantage of this method is that variables such as the bid strategy and ad copy stay the same in both arms. The downside is that it only covers ad traffic. Visitors from organic search and other channels stay outside the test.
Does A/B testing affect SEO?
A/B testing does not hurt SEO when you follow Google’s testing rules. Google states that small changes, such as button color or call-to-action text, often have little or no impact on a page’s search result snippet or ranking.[1] The risk comes from the technical setup of the test.
These are the core rules Google gives for A/B tests:[1]
- Don’t cloak: Showing one set of URLs to Googlebot and a different set to humans violates the spam policies, even during a test. This applies whether you do it with server logic or robots.txt.
- Use rel=“canonical”: If you test with multiple URLs, point the alternate URLs to the original page as canonical. Google recommends canonical rather than noindex in this situation.
- Use 302, not 301: If you redirect users from the original URL to a variant, use a temporary (302) redirect. JavaScript-based redirects are also fine.
- Don’t run the test longer than necessary: When the test ends, publish the winning version and remove the test code.
Google also reminds you that Googlebot generally does not support cookies. So in a cookie-controlled test, Googlebot sees the version a browser that does not accept cookies would see.[1] For the right canonical setup, see what is a canonical tag. I explain the difference between permanent and temporary redirects in the post on the 301 redirect.
How do you send A/B test results to GA4?
You send A/B test results to GA4 by sending which variant each user saw as an event parameter. You then build an audience or segment based on that parameter and compare conversions by variant. Google Analytics no longer has a built-in testing tool.
Google Optimize and Optimize 360 were sunset on September 30, 2023. Google announced that it is instead investing in third-party A/B testing solutions that integrate with GA4.[2] If you run tests on your own infrastructure, you can use the same integration logic.
According to Google’s integration guide, you create an identifier for each variant and write it to the exp_variant_string parameter of the experience_impression event. The event is sent when a user is added to a variant, for example when the experiment page loads.[3]
// Sends the variant information to GA4 when the variant page loads
gtag('event', 'experience_impression', {
// Recommended format: TOOL_ID-EXPERIENCE_ID-VARIANT_ID
exp_variant_string: 'SK-OFFER2026-B'
});
To avoid collisions across experiments and tools, Google recommends building the value from the tool, experience and variant IDs.[3] On the GA4 side, you define an audience for each variant based on this parameter. The post on GA4 conversion tracking is a good starting point for setting up the conversion events.
KVKK and consent
The cookie that pins the variant and the analytics events can fall under personal data processing. Under KVKK (Turkey’s personal data protection law) and the GDPR, you need user consent for analytics cookies. Users who decline consent can still be part of the test, but their behavior does not reach GA4 in the same detail. That is why I also track the consent rate per variant; if the consent rate differs between the two variants, the measured difference in conversions can be misleading. I explain how consent signals reach Google tags in the post on what Consent Mode v2 is. This section is not legal advice.
What should you test on a landing page?
The first things to test on a landing page are the elements that directly affect the user’s decision: the headline, the offer itself, the form structure and the call to action. Small visual details such as button color usually produce small differences. And detecting small differences, according to the table above, takes a lot of traffic.
My order of priority is usually:
- Headline and search match: Does the first sentence of the page say the same thing the ad promised?
- Offer and next step: Different next steps such as a free assessment, price information or a call request.
- Form structure: Number of fields, a multi-step or single-screen form, whether the phone field is required.
- Trust elements: Certifications, a description of the process, frequently asked questions.
- Page structure: Section order, a long or short page.
In sensitive sectors such as healthcare, I keep a clear line when testing trust elements. A variant with fabricated reviews, unreal before/after images or a guarantee cannot go live even if it wins. Content like that can run into both advertising policies and regulation.
How a higher conversion rate affects cost
Cost per acquisition (CPA) is calculated by dividing total ad spend by the number of conversions. With the same budget and the same traffic, a higher conversion rate means more conversions and a lower CPA. You can see the business impact of the winning variant with your own numbers in the calculator below.
Pre-launch checklist
Before launching a landing page A/B test, I check the items below one by one. Each item directly affects how reliable the result is.
Conclusion
A landing page A/B test, when set up correctly, turns design debates into measurable decisions. For a trustworthy test, the hypothesis, primary metric and sample size are set at the start. The variant is chosen at the server or edge layer, Google’s canonical and 302 rules are applied, and the variant information is sent to GA4.
As a next step, pick the landing page that receives the most paid traffic and run the sample size calculation with its current conversion rate. The calculation tells you what size of change you can test on that page. If you want to build the measurement and testing infrastructure on your own site, I describe how I work on the software development page.
Key terms
- A/B test
- An A/B test is a controlled experiment that shows two versions of a page or element to randomly split groups of users at the same time and measures which version performs better on a chosen metric. The current version is called the control and the new one the variant.
- Split URL test
- A split URL test is a type of A/B test in which each version being compared is published at its own URL and traffic is split between those addresses. It is the usual choice for landing page tests where the layout, template or flow changes completely.
- Minimum detectable effect
- Minimum detectable effect is the smallest difference a test can reliably detect at the chosen confidence and power levels. It is abbreviated MDE; the smaller you set it, the larger the sample you need.
- Sample ratio mismatch
- Sample ratio mismatch is a statistically significant deviation between the number of users assigned to each variant and the planned split ratio. It is abbreviated SRM and usually points to a redirect, cookie or measurement bug; the result of such a test should not be interpreted.
Frequently asked questions
How much traffic do you need to A/B test a landing page?
The traffic you need depends on your current conversion rate and the smallest difference you want to detect. A common approximation gives 16 × p × (1 − p) / δ² visitors per variant. On a page converting at 4 percent, detecting a 1-point difference works out to roughly 6,100 visitors per variant.
How long should an A/B test run?
A test should run until it reaches the sample size you calculated in advance, and for at least one or two full weeks. The full-week rule keeps weekday and weekend differences in behavior from distorting the result. Google also recommends keeping tests running only as long as necessary and removing test code and alternate URLs once they end.
Does A/B testing hurt SEO?
A/B testing does not hurt SEO if you follow Google's rules. Do not show Googlebot different content, point alternate URLs to the original page with rel="canonical", and use a 302 instead of a 301 if you need a redirect. When the test ends, publish the winning version and clean up everything the test left behind.
What should you use instead of Google Optimize?
Google Optimize and Optimize 360 were sunset on September 30, 2023. Google now points to third-party A/B testing tools that integrate with GA4. If you run tests on your own infrastructure, you can send variant information to GA4 with the experience_impression event.
Can you A/B test a landing page without a tool?
Yes. You can build two separate page URLs, split traffic randomly at the server or edge layer, and pin each visitor to a variant with a cookie. On the ad side, Google Ads custom experiments also split budget between two arms so you can compare different final URLs. In that case you have to handle the sample size calculation and significance check yourself.
Sources
The full topic: Software guide ↗