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.
- Page loadsOriginal hero and form paint
- Tool script runsPicks a variant for this visitor
- Hero swappedNew headline wraps to 3 lines, image is taller
- Layout jumpsForm and CTA move down
- 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.
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
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.
Look for the swapped element
If the moved element is the hero, banner or button your tool edits, the tool is the cause.
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.
Test each variant
Force each variant in turn using the tool's preview link. One variant is often much worse than the others.
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.
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.
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.
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.
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.
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.
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.
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.
.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;
}<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>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.
Follow vendor guidance
Some vendors recommend a direct install in the head instead of GTM for this reason. Check your tool's documentation.
Add the reserved-space CSS
Go to Appearance > Customize > Additional CSS (or your child theme stylesheet) and paste the min-height rules for the swapped container.
Load the script in the head
Use the tool's plugin if it has one, or your theme's header injection setting. Exclude the script from any plugin that delays JavaScript.
Set a min height on the section
Select the swapped section or div, open the Style panel and set Min Height to the tallest variant, using separate values per breakpoint.
Add the script in Project Settings
Put the tool snippet in Project Settings > Custom Code > Head Code.
Place the script in theme.liquid
If the tool has no app embed, add its snippet near the top of the head in theme.liquid. Edit a duplicate theme first.
Reserve the section height
Add the min-height CSS to your theme's base stylesheet for the section the tool edits. File names depend on the theme.
Render the variant on the server
Read the assignment from a cookie in your server or edge code and output the final HTML.
Fall back to CSS
Where you must swap in the browser, reserve space with min-height or aspect-ratio as shown above.
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
- 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
- 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.
Related issues
- PRF-025CLS over 0.1 on a funnel stepFix guide
- PRF-027Promo/announcement bar injected at top after loadFix guide
- PRF-029Embeds (YouTube, Instagram, reviews widget) resize after loadFix guide
- PRF-036Lazy-loaded section above the viewport shifts scroll positionFix guide
- PRF-038CTA moves just as user taps it (mis-click onto other element)Fix guide
- PRF-026Cookie banner pushes content down, CLS 0.3Fix guide