Welcome to WebmasterWorld Guest from 34.225.194.144

Forum Moderators: martinibuster

Message Too Old, No Replies

Setting up Adsense link units for responsive site

Is this code correct?

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

Full Member

10+ Year Member

joined:June 26, 2008
posts:268
votes: 5


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>
10:38 am on Sept 9, 2015 (gmt 0)

Junior Member

joined:Jan 17, 2015
posts:130
votes: 27


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>
12:25 am on Sept 17, 2015 (gmt 0)

Full Member

10+ Year Member

joined:June 26, 2008
posts:268
votes: 5


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>
7:55 am on Sept 17, 2015 (gmt 0)

New User

joined:Sept 15, 2015
posts:4
votes: 0


I have the similar trouble
Thanks magician for advice
11:06 am on Sept 17, 2015 (gmt 0)

Full Member

10+ Year Member

joined:May 25, 2006
posts:300
votes: 36


@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
9:41 am on Sept 18, 2015 (gmt 0)

Junior Member

joined:Jan 17, 2015
posts:130
votes: 27


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.
1:07 pm on Sept 18, 2015 (gmt 0)

Senior Member from US 

WebmasterWorld Senior Member netmeg is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month

joined:Mar 30, 2005
posts:13012
votes: 222


I would most certainly ask AdSense Support before implementing.
5:32 am on Feb 1, 2016 (gmt 0)

Junior Member

joined:Jan 17, 2015
posts:130
votes: 27


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

Join The Conversation

Moderators and Top Contributors

Hot Threads This Week

Featured Threads

Free SEO Tools

Hire Expert Members