Responsive AdSense

Responsive AdSense


Well-known member
Well I took the code that was posted here and just plugged my ca-pub-id and ad slot numbers into it.... and the ads come up and it works fine as you have it using the default style...but it doesn't work in UI.X. Strange.
Sorry if this has already been asked. I've been digging through this thread and others and haven't found an answer.

I need to use AdSense for smaller screens and a different ad service for larger screen sizes.

I can't load both ads and use @media queries and css display to show the correct one because that violates TOS.

Has anyone already done this?


XenForo moderator
Staff member
You need to use a custom solution (using JS for example) to prevent AdSense ads being served at certain widths.


Well-known member
I added the first code to the ad_thread_list_below_stickies and replaced the ad slot with my codes, but I don't see any ads showing up on my board. I'm new to the software, what am I missing?


Active member
I will have to ask some of my other company FORUMCAST's partner forums who are using Xenforo to see how they are serving our AdX tags with DFP in a responsive way.


Active member
Just wanted to say thanks again for the heads up on this.

I have now converted all of my ad templates to use the new beta code.

I should however that resizing the browser does not result in new ads being served, that still requires a refresh.
The only benefit so far is you don't need to create three or four different ad slots to cater for different widths, you just create a single ad slot and then add CSS like so:
<style type="text/css">
.overtaking-middle-dynamic { width: 320px; height: 50px; }
@media(min-width: 484px) { .overtaking-middle-dynamic { width: 468px; height: 60px; } }
@media(min-width: 744px) { .overtaking-middle-dynamic { width: 728px; height: 90px; } }

I would recommend not using the 468x60 ad unit for responsive Google ads based on viewport size because that size is deprecated in the ad world these days and the rates it pays are very very low compared to other sizes. Instead it might be better to use a medium box or one of the mobile banner sizes. They will earn you more money.


Well-known member

Anyone used the advanced rules for AdSense?
I was looking for this one where we can specify the ad size using @media query.

<style type="text/css">
.adslot_1 { width: 320px; height: 100px; }
@media (min-width:500px) { .adslot_1 { width: 468px; height: 60px; } }
@media (min-width:800px) { .adslot_1 { width: 728px; height: 90px; } }
<ins class="adsbygoogle adslot_1"
<script async src="//"></script>
<script>(adsbygoogle = window.adsbygoogle || []).push({});</script>


Active member
Hi Brogan,

Can i use Responsive Adsense to add a google adsense banner inside the poll block? I want to move the entire poll content to the right side, and on the left side i want it to show a google adsense banner.


Thank you!


Active member
Brogan submitted a new resource:

Responsive AdSense - Adverts R Us

Read more about this resource...

Hi @Brogan ,

Which template should i put this code?
<xen:if is="!in_array({$contentTemplate}, array('message_page', 'error', 'search_form', 'search_form_post', 'search_form_profile_post', 'search_results', 'register_form', 'register_facebook', 'register_twitter', 'register_google', 'login', 'error_with_login', 'contact'))">