Forum Moderators: martinibuster

Message Too Old, No Replies

Use of display: none to hide adsense on large screens

         

Bram_H

10:37 pm on Sep 7, 2014 (gmt 0)

10+ Year Member



Hi guys,

Long time lurker signed up to ask a burning question :)

Since we have redesigned our website to be fully responsive our adsense revenue for mobile has dropped to a ridiculous level.

Our site has two rectangle ads in the left sidebar that perform steady for desktop traffic but due to the ads being placed all the way down the site on a narrow mobile device I need to rework the placements of our "mobile" ads with responsive adsense.

Google now allows publishers to use display: none on responsive adsense code to hide content on small screens (see [support.google.com...] ) however I'd like to achieve the opposite. Hide an ad unit on the largest screens and only show them on mobile/tablet devices.

Using the trick in the link above simply using display: none won't hide the largest media query. Although when using the following code with display: none !Important; it does the job just fine.

<style>
.test { width: 320px; height: 50px; }
@media(min-width: 801px) { .test { display: none !Important; } }
</style>
<script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
<!-- test -->
<ins class="adsbygoogle test"
style="display:inline-block"
data-ad-client="ca-pub-XXXXXXX"
data-ad-slot="XXXXXXX"></ins>
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script>

Is the use of display: none !Important; allowed to hide adsense for desktop users? If so, my problems are finally solved and I can work on new mobile ad positions.

Thanks for the help!

[edited by: martinibuster at 2:15 am (utc) on Sep 8, 2014]
[edit reason] Fixed URL/"examplified" elsewhere. [/edit]

levo

12:57 pm on Sep 9, 2014 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



According to [support.google.com...] you can hide ad units "if you're implementing a responsive ad unit." I've just tested it and the code doesn't "fire" and ad request if the container is invisible.

Last year they've implemented Active View reporting. The code tracks that if 50% of the ad is seen for at least 1 second and pings /activeview. Check your performance reports - select Matched requests - to see how "viewable" your bottom ads are.

levo

2:22 pm on Sep 9, 2014 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Edit: Make sure that the ad unit itself is set to "display:none" - otherwise it renders the ad even if the container (and the ad) is invisible. (your example is correct)