Responsive AdSense

Responsive AdSense

@Anthony Parsons Do the media queries go in EXTRA.CSS?
Conditional... as per Brogan outlined. If you had a single ad in the post templates and wanted to stop it showing in best posts, you would just wrap your adsense using:

<xen:if is="!{$dark_bestposts_type}">
Adsense code here...
</xen:if>

I was lucky I happened to click best posts for something... and went, sh*t... with many ads showing down posts on the one page, clearly breaching Adsense policy. Doh moment!
 
Just implementing this for ad service style ads and am a little confused. How would the code be utilised for javascript or iframed adverts? If have a scrap of javascript detecting the screen size and want to display either one of 2 iframe or javascript supplied adverts depending on what the width is. I am shiny new to javascript hence my question...

Any help apprecaited

Cheers
 
This guide is specifically for Google AdSense.

If you are using a different ad server, you will be better off asking the service provider or posting a new thread.
 
Sorry, thought it had to do with using responsive ad display, will figure out out on my own. I'll probably need javascript somewhere down the track

Cheers
 
Is this still accurate for 1.4.3? I got my asynch Adsense code, but don't understand how I should be slotting in different adsense codes for the different breakpoints.

Just to confirm the resource is just a tutorial, not a download? Are the 'ad managers' helpful?
 
If you are using a different ad server, you will be better off asking the service provider or posting a new thread.
Do you have any suggestions for me if I plan to use basic image html code Brogan?
I've tried to implement this with <img src= but there is no way how the browser can take the window width since width = document.documentElement.clientWidth; applies for Adsense only.
 
Hi, wich is the template or conditionals for avoid show adsense in create-thread and moderadors and admin users?

With:

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', 'create-thread'))">

The adsense still appears at moment to create new thread in create-thread

Thanks for you great support.
 
Use is_moderator and is_admin, or the staff only user group ID, if you have one of those.
See this guide: http://xenforo.com/community/resources/conditional-statements.1604/

Hi with this code:

Code:
<xen:if is="!{$visitor.is_admin} OR {$visitor.is_moderator}">
<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', 'thread_create'))">

adsense code

</xen:if>
</xen:if>

The adsense still appears for admin and moderators user.

Any ideas?

Thanks fr you support.
 
I'm trying to figure this out... but my adsense code looks different than the one in your example....

Code:
<script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
<!-- 728 x 90  -->
<ins class="adsbygoogle"
     style="display:inline-block;width:728px;height:90px"
     data-ad-client="ca-pub-id"
     data-ad-slot="1234567890"></ins>
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script>

How do I modify that code to match this example? And how do I use different ads? Do I make different ad sizes in adsense and then plug in the data in your example?

I also noticed that Google also has an Adsense that is responsive itself... but when I put it in the ad_header slot nothing ever shows up. I think it's because of this:

The parent container has no width set. If you place your responsive ad code within a parent container that doesn’t have an explicit width set, for example, within a floating element, then our ad code won’t be able to calculate the required size for the responsive ad unit. In this case, you’ll need to modify your code and use CSS media queries to set the size of the parent container

https://support.google.com/adsense/answer/3213689?hl=en

Does the ad_header have no parent width set? I'm using UI.X.
 
I'm not sure where you got the AdSense code from - perhaps you are using a different service?
The code in the examples is from standard and asynchronous AdSense - you can get it from your AdSense account.

It's up to you which one you use and how many different ad slots you create.

I can't help with UI.X, I don't use it but the explanation from Google advises what needs to be done.
 
I'm not sure where you got the AdSense code from - perhaps you are using a different service?
The code in the examples is from standard and asynchronous AdSense - you can get it from your AdSense account.

It's up to you which one you use and how many different ad slots you create.

I can't help with UI.X, I don't use it but the explanation from Google advises what needs to be done.
That's the code (with numbers of accounts changed) gotten directly from google.
 
I'm trying to figure this out... but my adsense code looks different than the one in your example....

Yours looks like a standard 728 x 90 fixed-size ad slot - AFAIK you need to create a reponsive ad unit - like this:

upload_2015-2-26_0-47-24.webp
 
This is the Google Adsense responsive code directly from Google Adsense. It looks very different from the code posted in the example @Brogan

How do I modify this to make it work?

Code:
<script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
<!-- Responsive Ad -->
<ins class="adsbygoogle"
     style="display:block"
     data-ad-client="ca-pub-id"
     data-ad-slot="1234567890"
     data-ad-format="auto"></ins>
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script>
 
Top Bottom