Forum Moderators: martinibuster

Message Too Old, No Replies

Setting up Adsense link units for responsive site

Is this code correct?

         

virtualreality

9:22 pm on Sep 8, 2015 (gmt 0)

10+ Year Member Top Contributors Of The Month



Hello,
I am trying to set up my link units to appear on larger screens only and everything under 937px to not see the link ads.
I read the guidelines but I would like to double check if my code is correctly modified. I appreciate your feedback!

<style type="text/css">
@media (max-width: 937px) { .adslot_1 { display: none; } }
</style>
<ins class="adsbygoogle adslot_1"
style="display:inline-block;width:180px;height:90px"
data-ad-client="XXXXXX"
data-ad-slot="XXXXX"></ins>
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script>

magician

10:38 am on Sep 9, 2015 (gmt 0)

10+ Year Member Top Contributors Of The Month



It will be better if you keep all styling within <style> tag. I also added async tag - remove it if you don't need it.

<style type="text/css">
.adslot_1 { display:inline-block; width: 180px; height: 90px; }
@media (max-width:937px) { .adslot_1 { display: none; } }
</style>
<ins class="adsbygoogle adslot_1"
data-ad-client="XXXXXX"
data-ad-slot="XXXXXX"></ins>
<script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
<script>(adsbygoogle = window.adsbygoogle || []).push({});</script>

virtualreality

12:25 am on Sep 17, 2015 (gmt 0)

10+ Year Member Top Contributors Of The Month



Thanks for your help. I decided not to hide link units since I was not sure it is ok with Adsense. They say:
"Hiding ad units at anytime (e.g., display:none), unless you're implementing a responsive ad unit. " Link units are not responsive so I decided not to go ahead. But I am hiding an ad for a small screen max-width:400px. I would like to get your opinion if this code set up is correct:

<script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
<style type="text/css">
.adslot_1 { display:block; }
@media (max-width: 400px) { .adslot_1 { display: none; } }
</style>
<ins class="adsbygoogle adslot_1"
data-ad-client="xxxxxx"
data-ad-slot="xxxxxx"
data-ad-format="auto"></ins>
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script>

natalystickens

7:55 am on Sep 17, 2015 (gmt 0)



I have the similar trouble
Thanks magician for advice

Rasputin

11:06 am on Sep 17, 2015 (gmt 0)

10+ Year Member



@natalystickens, you should not use this code, according to adsense guidelines media queries and display:none can only be used with responsive ads, not with link units

magician

9:41 am on Sep 18, 2015 (gmt 0)

10+ Year Member Top Contributors Of The Month



I believe that the code is okay with google adsense policy as there is no ad request generated on smaller screens.

I had this query a year back and asked the same question here - [stackoverflow.com...] - Someone suggested this answer and I then confirmed with adsense help and they kinda said okay to it in their own vague language.

Anyway, I've been using this code on multiple sites since last one year.

netmeg

1:07 pm on Sep 18, 2015 (gmt 0)

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



I would most certainly ask AdSense Support before implementing.

magician

5:32 am on Feb 1, 2016 (gmt 0)

10+ Year Member Top Contributors Of The Month



An update to this question. Google has officially launched responsive ad link units in adsense. [support.google.com...]