/ โ† CLS Debugger Fixes / CLS from Ads
In this guide
  1. Why ads shift the page
  2. Tracing a shift back to an ad
  3. Choosing how much space to reserve
  4. Slots that come back empty
  5. Where slots sit matters as much as their size
  6. The fix, step by step
  7. Notes for common set-ups
  8. Keeping ad shifts under control
  9. Questions and answers

Why ads shift the page

An ordinary image comes from your own server and its size is known in advance. An ad is different. The page asks an ad server what to show, an auction or selection takes place, the winning creative is fetched, and only then is it drawn. That can take well over a second on a phone, by which time the reader has started scrolling through the text around the slot.

If the container is a plain <div> with no height, it takes up no space until the creative arrives. When a 250-pixel-tall unit is written into it, everything below drops by 250 pixels. That is one layout shift, often a large one, because it moves most of the visible screen.

Several things make ads harder than other late content:

๐Ÿ’ก Ads served in an overlay that sits above the page, such as a correctly built anchor unit at the bottom of the screen, do not move your content and do not count as layout shifts. The problem is ads that sit inside the normal flow of the page.

Tracing a shift back to an ad

The CLS Debugger names the elements that moved. With ads, those are usually your own paragraphs, headings or sidebar blocks, not the ad itself, because the ad is what appeared and pushed them. Look for a slot container directly above the moved element.

  1. Compare with ads blocked. In Chrome DevTools, open the Network panel, find the requests to your ad provider's domains and block them, then reload. If most of the CLS disappears, ads are the main source. Remember to unblock them afterwards.
  2. Record a throttled load. In the Performance panel with network and CPU throttling on, record a reload and scroll through the article. The Layout shifts track shows each shift; select one and the highlighted nodes show what moved and by how far.
  3. Check the served sizes. Right-click each filled slot and inspect it. Note the width and height of the creative's iframe. Do this several times across different page loads, because the size can change from one visit to the next.
  4. Look at the empty cases. Reload a few times on a low-traffic page or use a test ad unit with no campaigns. If the slot container shrinks to zero, you have a no-fill shift as well.

If you use Google Ad Manager, its publisher console, opened from the browser console or with a URL parameter, lists each slot, the sizes requested and the size delivered, which saves a lot of manual inspecting.

Choosing how much space to reserve

Reserving space means giving the slot container a min-height (and usually a min-width) before any ad code runs, so the box is already the right size when the creative lands. The hard part is picking the number when the slot can take several sizes.

Slot set-upWhat to reserveTrade-off
One fixed size, such as 300 x 250Exactly that heightNone; this is the ideal case
Several sizes, one usually winsThe height of the size that wins most often, from your reportingA taller creative still shifts, but rarely
Several sizes, no clear winnerThe tallest sizeSmaller creatives leave a gap; no shift
Different sizes on mobile and desktopA separate height per breakpointMore CSS to maintain
Fluid or native units with variable heightA realistic minimum, and place the slot below the first screenSome movement may remain

A simple, readable pattern is a class per slot type, sized with media queries that mirror your ad server's size mapping:

<div class="ad ad--in-article" id="ad-article-1"></div>

.ad { display: flex; align-items: center; justify-content: center;
      margin: 24px auto; background: #f3f3f3; }
.ad--in-article { min-width: 300px; min-height: 250px; }
.ad--leaderboard { min-height: 50px; }
@media (min-width: 768px) {
  .ad--leaderboard { min-height: 90px; }
}
@media (min-width: 1024px) {
  .ad--in-article { min-height: 280px; }
}

A light background and a small "Advertisement" label make the reserved box look intentional while it waits, and tell readers what is coming. Keep the label outside the ad container if your network does not allow extra content inside it.

โš ๏ธ Restricting a slot to fewer sizes, or leaving a gap when a smaller creative wins, can change how much the slot earns. Look at your own reporting before and after, and discuss major changes with your ad partner. This guide cannot predict the revenue effect for your site.

Slots that come back empty

When there is no ad to show, many set-ups hide the slot. That feels tidy but it moves content twice: down if something briefly appeared, or up when the reserved box disappears.

In Google Publisher Tag the behaviour depends on how you call collapseEmptyDivs:

Keeping the space is better for CLS. To avoid a blank rectangle, fill it with a house advert for your own newsletter or products, or a neutral placeholder. Other networks have similar settings; look for options named along the lines of "collapse empty" or "hide unfilled".

Where slots sit matters as much as their size

A shift is scored by how much of the screen moved and how far. A leaderboard at the very top of the page, above the headline, moves the entire visible page when it opens. The same unit halfway down an article, loaded before the reader reaches it, may move nothing they can see.

Automatically placed ads

Features that choose ad positions for you, such as automatic placement in some ad networks, insert new containers wherever the script decides. You cannot reserve space for a slot you do not know about. If they cause heavy shifting, reduce the formats they may use, exclude areas of the page where your network allows it, or replace in-page automatic units with fixed, manually placed slots that you can size.

Refreshing and expanding units

If slots refresh while visible, request only sizes that fit the reserved box so a refresh cannot change the height. Expanding creatives should expand over the content rather than pushing it, which most ad policies already require.

The fix, step by step

Step 1

Map every ad slot and its sizes

List each ad position on your main templates: article, category, home page and any others that carry ads. For each one record the container's id or class, where it sits on mobile and desktop, every size it is allowed to serve at each breakpoint, and whether it is placed by you or inserted automatically. Your ad server or network dashboard holds the size settings; the page template tells you where the containers are.

Step 2

Find which slots cause the biggest shifts

Run the CLS Debugger on each template and note the largest shifts and the elements that moved. For each, find the ad container directly above the moved content. Confirm by blocking the ad provider's domains in Chrome DevTools and reloading: the shift should vanish. Rank the slots by the size of the shift they cause, and start with anything above the first screen or at the top of the article.

Step 3

Reserve a minimum height per breakpoint

Give each slot container a class with a min-height and min-width set in your main stylesheet, not by the ad script, so the space exists from the first paint. Use the single size if the slot has one, otherwise the most common winning size or the tallest. Add media queries so mobile and desktop heights match your ad server's size mapping, and give the box a light background and label.

Step 4

Stop empty slots collapsing

Check whether your ad code collapses slots that receive no ad. In Google Publisher Tag, remove calls to collapseEmptyDivs, especially collapseEmptyDivs(true), which keeps slots shut until filled. For other networks, turn off any setting that hides unfilled units. Then decide what to show in an unfilled box, such as a house advert or a neutral placeholder, so readers do not see an unexplained gap in the page.

Step 5

Move or restrict the worst slots

For slots that still shift because their creatives vary widely in height, either limit them to sizes that fit the reserved box or move them lower in the page, below the first screen, where fewer readers see any movement. Consider removing a leaderboard that sits above the headline on mobile. Compare earnings for the changed slots over a few weeks, and agree larger changes with your ad partner before making them.

Step 6

Control auto-placed, sticky and refreshed ads

If your network inserts in-page ads automatically, limit the formats it uses or switch to fixed slots you can size. Inspect sticky and anchor units and confirm they use position: fixed over the content rather than being inserted into it. For refreshing slots, allow only sizes that fit the reserved height, so a new creative never changes the size of the box while someone is reading.

Step 7

Verify with ads on and off

Run the CLS Debugger again on each template, then record throttled loads in DevTools several times, because each load may serve a different creative. Repeat with the ad domains blocked to make sure the reserved boxes do not cause problems of their own. Scroll through long articles while recording. Finally, watch the mobile Core Web Vitals report in Search Console, which reflects the real mix of ads visitors get.

Notes for common set-ups

Keeping ad shifts under control

Questions and answers

1. Do ads count towards my Cumulative Layout Shift score?

Yes. Google measures layout shifts on the page as the visitor experiences it, and it does not matter whether the content that caused the movement came from your server or an ad network. An ad container that opens up after the text has been drawn pushes that text down, and the movement is counted like any other shift. Ads in overlays that do not move your content, such as properly built anchor units, do not add to the score.

2. How much height should I reserve for an ad slot with several sizes?

Look at your ad reporting to see which size wins most often in that slot. If one size clearly dominates, reserve its height and accept an occasional shift when a taller one wins. If sizes are evenly split, reserve the tallest, so nothing ever moves, and accept a gap around smaller creatives. Set different heights for mobile and desktop to match the sizes each breakpoint is allowed to serve, and review them when sizes change.

3. Should I collapse ad slots that do not fill?

For layout stability, no. Collapsing an unfilled slot removes space that the reader has already seen, so the content below jumps up, which counts as a shift. Collapsing slots until they fill is worse, because every filled slot then pushes content down. Keeping the reserved box and filling it with a house advert or a subtle placeholder avoids both. If you must collapse, do it only for slots well below the first screen.

4. Will reserving ad space reduce my ad revenue?

It might change it, in either direction, and the effect depends on your site, audience and ad partner. Reserving space itself does not stop ads serving, but limiting a slot to fewer sizes can reduce competition for it, and moving slots lower can change viewability. Measure earnings for each changed slot for a few weeks and compare with the previous period. Some publishers also find readers stay longer when the page stops jumping.

5. Do sticky ads cause layout shift?

Not if they are built as overlays. An anchor ad fixed to the bottom or top of the screen with position fixed sits above the content and does not move it. Problems arise when a so-called sticky unit is actually inserted at the top of the page and pushes the article down, or when a sticky sidebar changes height as its ad loads. Inspect the element and check its position style to see which you have.

6. Can lazy loading ads reduce layout shift?

Lazy loading reduces the work done at page load and means fewer ads load that nobody sees, but it does not stop shifts by itself. A lazy slot that opens up just as the reader scrolls to it still pushes content. It helps when combined with reserved space: the box is already the right size, and the ad simply appears inside it. Fetch lazy slots a little before they enter the screen so they are ready in time.

Find out which ad slots are moving your content

The CLS Debugger records the layout shifts that happen while your page loads, names the elements involved, totals the cumulative score and ranks every shift by how much it contributes, so the ad slots doing the most damage stand out.

Open CLS Debugger Fixes โ†’
๐Ÿ’ฌ Got a problem?
Related Guides: All CLS Debugger Fixes  ·  CLS from Dynamic Content  ·  Third-Party Tags  ·  CLS Debugger Guide  ·  Learning Hub

About aiwebpageseo

aiwebpageseo.com is a data-driven SEO and AEO (Answer Engine Optimisation) platform providing a free suite of technical SEO tools. Rather than relying on AI-theorised assumptions, the platform analyses live URL performance, delivering objective diagnostics, page speed metrics, CLS debugging, and site crawl data alongside actionable technical tutorials.