How I Run A/B Tests in Webflow Without Using Third-Party Tools

How I Run A/B Tests in Webflow Without Using Third-Party Tools A/B testing is a powerful way to optimize your website, but most guides assume you’ll be using tools like Google Optimize, Optimizely, or expensive SaaS platforms. But what if you want to run simple A/B tests on your Webflow site, without relying on third-party tools?

Read time:
2 minutes
Author:
Bojana Djakovic
Published:
July 25, 2025

How I Run A/B Tests in Webflow Without Using Third-Party Tools
A/B testing is a powerful way to optimize your website, but most guides assume you’ll be using tools like Google Optimize, Optimizely, or expensive SaaS platforms.

But what if you want to run simple A/B tests on your Webflow site, without relying on third-party tools?

That’s exactly what I started doing on client projects when I needed light experiments for headlines, calls to action, or design tweaks.

In this post, I’ll show you how I set up basic A/B tests in Webflow using just JavaScript and the Webflow CMS, without the need for external tools.

What types of A/B tests can you run this way?

You can easily test variations such as:

  • Headlines or text
  • Call-to-action button colors or wording
  • Hero section images
  • Different section layouts

Ideal for small experiments on static pages, landing pages, or CMS templates

Basic concept

  • Randomize on page load Instead of using a testing platform, you can write a simple script that:
  • Randomly displays version A or version B when the page loads
  • Track the result using Webflow’s native templates or Google Analytics events

Example 1 : A/B test on headline text

HTML in Webflow:
Place both versions of the headline inside a div and assign them classes:

<h1 class="headline headline-a">Get 50% off your first order!</h1>
<h1 class="headline headline-b">Try us today — 50% off!</h1>

JavaScript for Randomization:

document.addEventListener("DOMContentLoaded", function() {
const showA = Math.random() < 0.5;
document.querySelector('.headline-a').style.display = showA ? 'block' : 'none';
document.querySelector('.headline-b').style.display = showA ? 'none' : 'block';
});

Example 2 : A/B test button color

In your Webflow Designer, create two buttons with different styles and wrap them in a div.

The JavaScript will show one and hide the other on load, just like with the headline.

How do I track results?

You'll want to track conversions or clicks for each variation.
Here’s how I did it:

  • Events in Google Analytics -Fight an event when a user clicks a call-to-action button using gtag() or dataLayer.push()
  • Webflow forms-Add a hidden input with the variation name and pass it when users submit the form
  • Simple click counter with JavaScript-Store results in Google Sheets or Airtable via webhook

Use Webflow CMS for dynamic A/B content

If you want to A/B test content on CMS collection pages, you can:

  • Add a toggle or option field to select a variant in the CMS
  • Use conditional visibility to show the correct version based on CMS data
  • Randomly arrange only certain elements while letting the CMS control the rest

Limitations of this method

This works great for simple A/B tests, but:

  • No automatic statistical analysis
  • Will not perfectly balance traffic between versions (randomness is not accurate)
  • You will have to manually analyze the results in GA or Sheets

Why I use this method on Webflow Projects?

  1. No external scripts or tracking pixels
  2. Full control over styling within Webflow
  3. Keeps the page lightweight
  4. Ideal for small-scale experiments

You don't need expensive tools to start testing and improving your Webflow site.
With a little JavaScript and Webflow's native features, you can run basic A/B tests, collect data, and make informed design decisions all without leaving your project.

Back to blog page