Responsive AdSense

Responsive AdSense

cdub

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?
 

Brogan

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

ActorMike

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?
 

tribedude

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.
 

tribedude

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:
Code:
<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; } }
</style>

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.
 

Nuno

Well-known member
Hi,

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

Code:
<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; } }
</style>
<ins class="adsbygoogle adslot_1"
    style="display:inline-block;"
    data-ad-client="ca-pub-1234"
    data-ad-slot="5678"></ins>
<script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
<script>(adsbygoogle = window.adsbygoogle || []).push({});</script>

https://support.google.com/adsense/answer/3543893#adv
 

LogOn

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.

Capture.JPG

Thank you!
 

clove28

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?
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'))">
 
Top