Forum Moderators: martinibuster

Message Too Old, No Replies

Convert regular AdSense units into responsive ones in an easy way

Leaving the 'data-ad-client' and 'data-ad-slot' information

         

guarriman

4:29 pm on Feb 17, 2015 (gmt 0)

10+ Year Member



Hi

I am changing the HTML design of my website, converting all the pages into responsive ones. I am also planning the conversion of the AdSense units of the pages into responsive ones, and wondered if the transformation is as easy as the following.

This is the piece of code of one of the current AdSense units:

<script type="text/javascript"><!--
google_ad_client = "ca-pub-XXXXXXXXXXXXXXX";
google_ad_slot = "YYYYYYY";
google_ad_width = 300;
google_ad_height = 250;
//-->
</script>
<script type="text/javascript"
src="">
</script>


Would it be as easy as adding the 'data-ad-format', removing the 'google_ad_width' and 'google_ad_height', and leaving the information of 'data-ad-client' and 'data-ad-slot'?

<script async src="//"></script>
<ins class="adsbygoogle"
style="display:block"
data-ad-client="ca-pub-XXXXXXXXXXXXXXX"
data-ad-slot="YYYYYYY"
data-ad-format="auto"></ins>
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script>

I mean, I do not want to remove my current custom channels and create new ones, and wondered if they would work with a new responsive design.

Thank you very much.

netmeg

5:02 pm on Feb 17, 2015 (gmt 0)

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



Interesting question, and I don't know. I'm not sure if you *must* create the new ad units in the User Interface, or if you can just effect changes on your own. That's probably a question for AdSense support, if you qualify. I'd be interested in hearing if you get an answer.

(Your channels should work with any ad you assign them to, but whether or not you can assign them outside of the console I don't know. It does create a unique Ad ID, so maybe not)

davidof

5:08 pm on Feb 17, 2015 (gmt 0)

10+ Year Member



I can't see the reporting working right without first creating the ad in the console because it will be getting clicks on ads it doesn't know about. So i agree with nutmeg.

ember

6:13 pm on Feb 17, 2015 (gmt 0)

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



There is also something in the TOS about not fiddling with the ad code. I have done so in the past but only with advance permission and then only because my software was adding extra information to the code. As Netmeg says, check with support.

netmeg

6:54 pm on Feb 17, 2015 (gmt 0)

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



nutmeg


ahem.

There is also something in the TOS about not fiddling with the ad code


Yea. I'd have to look it up - they've loosened up on that a bit, but I think you're still only supposed to adjust the CSS, and if you have more than one async or responsive ad on a page, you can remove that last <script> from all the ads after the first one.

ember

10:33 pm on Feb 17, 2015 (gmt 0)

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



Nevermind.

farmboy

3:15 pm on Feb 18, 2015 (gmt 0)

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



nutmeg


ahem!




There must be an inergallatic glitch in that Internet cloud thingy.



FarmBoy

alika

4:11 pm on Feb 18, 2015 (gmt 0)

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



... if you have more than one async or responsive ad on a page, you can remove that last <script> from all the ads after the first one.


Is this why I can't make any other ads responsive? I've been trying forever to change all my ads to responsive, but got only 1 to do it, and not the others.

Thanks for the tip!

netmeg

10:28 pm on Feb 18, 2015 (gmt 0)

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



Well it might have something to do with how you're implementing it. I use Google Tag Manager, and I actually moved the script from *all* the ads and just serve it once in the GTM - mostly for performance reasons. But having the script on each ad unit should still work, I'd think.

RedBar

9:22 pm on Feb 19, 2015 (gmt 0)

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



you can remove that last <script> from all the ads after the first one.


I've never heard of that before and I have a lot of pages with two responsive ads and zero issues insofar as I am aware.

netmeg

9:58 pm on Feb 19, 2015 (gmt 0)

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



Right, it shouldn't prevent ads from showing. You only need to have *one* call to that script though, and under heavy traffic I want to optimize all that I can, so I took the script off all the ads, and call it only once with an include on the page (or rather, with GTM)

If you don't have it at least once though, your ads won't show.

RedBar

11:08 am on Feb 20, 2015 (gmt 0)

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



Ah, ok, I also serve via an include, I'll bear this in mind if I ever get back to heavy traffic numbers....that's very doubtful!