Skip to content
FunnelGuard

Fix guide by FunnelsGuard

CLS from A/B testing and personalisation tools: how to fix it

PRF-037Medium impactPartlyBy FunnelGuardPublished Updated
On this page

What this issue is

Cumulative Layout Shift (CLS) is a score for how much visible content moves unexpectedly while a page loads. Google treats a score of 0.1 or lower as good.

Testing and personalisation tools usually run in the browser. The page loads the original version first. Then a script decides which variant you get and rewrites the page: a new hero headline, a different image, a changed button or a whole new banner. If the new block has a different height than the original, everything below it jumps. Visitors sometimes also see the original flash before the variant appears. That is called flicker.

How the swap causes a shift
  1. Page loadsOriginal hero and form paint
  2. Tool script runsPicks a variant for this visitor
  3. Hero swappedNew headline wraps to 3 lines, image is taller
  4. Layout jumpsForm and CTA move down
  5. Mis-click or exitVisitor taps the wrong thing or leaves

The original hero paints first, then the tool replaces it with a taller variant.

Why it costs you leads or sales

A shift right after load moves the button or form field a visitor was about to use. They tap the wrong element, lose their place or leave. The page also feels untrustworthy, which hurts most on a landing page where you get one chance.

There is a second cost. If the shift hits only some variants, your test is biased. A variant that causes a jump may lose because of the jump, not because of its message. You then pick a winner for the wrong reason.

Form starts by variantExample numbers
Form starts by variant (example)Control (no shift): 12 %; Variant B (shifts): 9 %; Variant B (space reserved): 12.5 %051012912.5Control (no shift)Variant B (shifts)Variant B (space rese…%

Example: the same message loses when one variant shifts the form down after load. Numbers are illustrative.

How to check if your site has it

Find shifts caused by the tool
  1. Record the load in Chrome DevTools

    Open DevTools, go to Performance, tick Screenshots and reload with recording. In the Experience track, click each red Layout Shift entry to see which element moved.

  2. Look for the swapped element

    If the moved element is the hero, banner or button your tool edits, the tool is the cause.

  3. Compare with the tool switched off

    Load the page with the tool paused, or use its preview or QA mode to force the original, and compare the CLS.

  4. Test each variant

    Force each variant in turn using the tool's preview link. One variant is often much worse than the others.

  5. Check field data

    In PageSpeed Insights or the Search Console Core Web Vitals report, look at real-user CLS for the URL. Field data can lag by weeks.

A variant lands late

The page looks ready, then the swapped block pushes the form away.

How to fix it

The goal is that the final layout is known before the variant arrives. Pick the option that fits how your tool works.

Stop the swap from moving content
  1. Reserve space for the swapped block

    Give the container a fixed or minimum height, or an aspect ratio for images, sized to the tallest variant. Check it on mobile widths too, where headlines wrap more.

  2. Keep variants the same size

    Brief designers to match the height of headline, image and button across variants. Change text and colour, not layout, where you can.

  3. Load the tool script early

    Place it high in the head, synchronous or as your vendor recommends, so the change applies before first paint. Do not delay it through a tag manager if the vendor advises a direct install.

  4. Use the vendor's anti-flicker option carefully

    Many tools hide the page briefly until the variant is ready. Set a short timeout so a slow script never leaves a blank page.

  5. Prefer server-side or edge variants

    If you can, choose the variant on the server and send the final HTML. No swap happens, so nothing shifts.

  6. Avoid injecting new blocks above existing content

    If a variant adds a banner or a section, put it in a space that already exists or reserve its space in the original page.

Reserve space for a swapped herocss
.hero-slot {
  min-height: 360px; /* height of the tallest variant on desktop */
}
@media (max-width: 600px) {
  .hero-slot {
    min-height: 480px; /* longer headline wraps on mobile */
  }
}
.hero-slot img {
  aspect-ratio: 16 / 9;
  width: 100%;
  height: auto;
}
Anti-flicker with a short timeout (generic pattern)html
<style>.ab-hide{opacity:0 !important}</style>
<script>
  document.documentElement.classList.add('ab-hide');
  setTimeout(function () {
    document.documentElement.classList.remove('ab-hide');
  }, 400); // always reveal after 400 ms
  // Your testing tool should also remove the class when the variant is applied.
</script>
Where to apply this
  1. Check how the tool loads

    If the testing script is a tag, set it to fire on Initialization or Page View as early as possible, not on Window Loaded or DOM Ready.

  2. Follow vendor guidance

    Some vendors recommend a direct install in the head instead of GTM for this reason. Check your tool's documentation.

Hero swap, before and after

Before

  • Tool loads late, after the page paints
  • Hero container has no set height
  • Variant is taller and pushes the form down

After

  • Tool loads early in the head
  • Container reserves the tallest variant's height
  • Form stays in place whichever variant shows

How to confirm it's fixed

Confirmation checks
  • Reload each variant in DevTools Performance and confirm no red Layout Shift entry on the swapped element.
  • Test on a throttled connection (Network: Fast 4G, CPU: 4x slowdown) so late scripts show up.
  • Check mobile widths, where text wraps and shifts are larger.
  • Run PageSpeed Insights and confirm lab CLS is 0.1 or lower.
  • Watch field CLS in Search Console over the next weeks.

How to prevent it happening again

Habits that keep tests clean
  • Add a layout check to your test QA: load every variant and watch for movement before launch.
  • Give designers a size budget for swapped blocks.
  • Keep the testing script early and re-check after theme or tag manager changes.
  • Retire finished tests so unused code stops running.
  • Prefer server-side variants for tests on the top of the page.

How FunnelGuard handles this

FunnelGuard detects this issue only partly. Its robot visitor runs your funnel pages on a schedule and checks CLS only. If the layout shift on a step goes over the threshold after a tool swaps content, you get one alert, after a re-check from a second region, with a screenshot and a likely cause.

Questions people ask

Why does my A/B testing tool cause layout shift?

Most tools run in the browser and change the page after it has first painted. If the new headline, image or banner is a different size from the original, the content below moves. That movement is counted in Cumulative Layout Shift.

How do I stop A/B test flicker and CLS?

Load the testing script early in the head, reserve space for the element being swapped, and keep variants close in size. Where possible, choose the variant on the server so the page arrives in its final form. An anti-flicker snippet can hide the page briefly, but use a short timeout.

Does personalisation hurt Core Web Vitals?

It can. Browser-side personalisation that swaps content after load adds layout shift and can delay the largest paint. Server-side personalisation avoids most of this because the final HTML is sent immediately.

What is a good CLS score?

Google considers a CLS of 0.1 or lower good, 0.1 to 0.25 needs improvement and above 0.25 poor. Measure on mobile as well as desktop, since wrapped text often shifts more.

How do I find which element my testing tool is shifting?

Record a page load in Chrome DevTools Performance and open the Experience track. Click each Layout Shift entry to see the element that moved. If it is the block your tool edits, you have found the cause.

Should I use an anti-flicker snippet?

Only with a short timeout, such as a few hundred milliseconds. It hides the page until the variant is ready, which stops visible flicker but delays content. It does not replace reserving space for the swapped block.

Can FunnelGuard tell me which A/B variant causes CLS?

No. FunnelGuard checks CLS only on your funnel steps and alerts you when it goes over the threshold. Finding the variant means previewing each one in your testing tool and recording it in DevTools.

Does FunnelGuard catch this?

Partly

FunnelGuard checks part of this.

How: CLS only.

Stop finding out from your customers

FunnelGuard runs your real forms and checkouts on a schedule, checks the tracking and the leads behind them, and alerts you once, with a screenshot. Try any paid plan free for 3 days.