Mavisss
Mavisss

Reputation: 41

Hide Google Adsense banner when there's no advertisments on Website

I have some problems when trying to integrate Google Adsense to my Weather Website.

  1. The google banner is running but not well. Sometimes, it doesn't show anything except for a blank banner. Like in this pic: Picture

  2. The first problem leads me to think about hiding the banner when there's no ads loaded. I found a solution which is adding data-ad-format="auto" to the banner tag. But I need to customize the banner dimension for the mobile. If I use data-ad-format="auto", I will not be able to customize the dimensions of the banner.

Does anyone has a solution for this? Hiding the banner when there's no ads?

Thank you very much!

Upvotes: 3

Views: 2348

Answers (2)

Nazarudin
Nazarudin

Reputation: 1067

You can hide the element if no ads using this:

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

or only show element if there is and ad using this:

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

source: https://support.google.com/adsense/answer/10762946?hl=en

Upvotes: 1

Ryan NZ
Ryan NZ

Reputation: 626

I have had this problem for quite a while, the first ad unit above the fold does not collapse (with collapse set within Adsense), yet the ads below the fold will collapse. I have read that it will work if you integrate it with Google Ad Manager though I haven't had time to test it yet

Upvotes: 2

Related Questions