Is it safe to remove unfilled AdSense ad units?

If you've ever experienced issues with manually placed ads not showing on your page, you're likely encountering the unfilled ad issue within your ins element, as indicated by data-ad-status="unfilled", according to Google. AdSense ad units sometimes remain unfilled after the ad request. In this tutorial, we'll explore whether it's safe to remove these unfilled ad units and how to handle them effectively, all in accordance with Google AdSense guidelines. The output in your element inspector will resemble the example below:

<ins class="adsbygoogle" style="display:inline-block;width:728px;height:90px" data-ad-client="xx-xxx-xxxxxxxxxxxxxxxx" data-ad-slot="xxxxxxxxxx" data-adsbygoogle-status="done" data-ad-status="unfilled">

Understanding AdSense Ad Units Status

AdSense updates ad units with a parameter called data-ad-status after the ad request. This parameter indicates whether the ad unit was filled with an ad or remained unfilled. There are two possible values:

  • data-ad-status="filled": An ad was returned and is now showing.
  • data-ad-status="unfilled": No ads were returned, and the ad unit is empty.

Handling Unfilled Ad Units

When ad units are unfilled, AdSense either collapses the ad unit or shows a blank space. The behavior depends on whether collapsing would cause page reflow. For ad units outside the viewport, AdSense collapses them. For other unfilled ad units, it retains the ad unit size and shows a blank space.

How to Hide Unfilled Ad Units

You can choose to hide unfilled ad units using CSS or JavaScript. Here's how you can do it:

Example 1: Hiding unfilled ad units using CSS

<style>
  ins.adsbygoogle[data-ad-status="unfilled"] {
    display: none !important;
  }
</style>

Example 2: Showing an image if the ad unit is unfilled

<style>
  ins.adsbygoogle a {
    display: none !important;
  }
  ins.adsbygoogle[data-ad-status="unfilled"] a {
    display: block;
  }
</style>

Limitations

There are some limitations to keep in mind:

  • The data-ad-status parameter is only added to ad units on the top window, so it won't work for ad units served via a cross-domain window.
  • It's not recommended to load AdSense ad units initially hidden because AdSense may not execute the ad request for those ad units.

Considering these limitations, it's essential to assess whether removing unfilled ad units aligns with your website's goals and AdSense performance.

That's it! You've learned how to handle unfilled AdSense ad units effectively. Remember to weigh the benefits against the limitations before deciding to remove them.


Last updated

Comments

Leave a Comment