How to make adsense ads responsive

Google is supporting the revolutionary responsive web-design technology it was important to allow compatible ads according website need. Till now it was very confusing to adopt the responsive ads due to no clear stand responsive AdSense code modification.

You must read : How to make Responsive web design.

On one hand Google was promoting responsive web design, on another hand there was no easy way to implement AdSense on such site without modifying the code. This is why they allowed to modify AdSense code in certain way (This is a really good news. Isn’t it?)

How to make adsense ads responsive,Google allows responsive AdSense officially,AdSense and Responsive Design Google AdSense,responsive ads,responsive google adsense

Now i'll tell you how can you do that
<script type="text/javascript">
google_ad_client = "ca-publisher-id",
if (window. innerWidth> = 800) {
google_ad_slot = " ad-unit-1 ";
google_ad_width = 728;
google_ad_height = 90;
} Else if (window.innerWidth <400) {
google_ad_slot = " ad-unit-2 ";
google_ad_width = 300;
google_ad_height = 250;
Else {}
google_ad_slot = " ad-unit-3 ";
google_ad_width = 468;
google_ad_height = 60;
}
</ script>
<script type = "text / javascript"
src = " http://pagead2.googlesyndication.com/pagead/show_ads.js ">
</ script>
Note:
  1. If you're using blogger then you need to parsing this code before implementing
  2. Above code is not work in Internet Explorer 8.
If you think this post is useful for you then give some time to comment and feel free for suggestion if any.
0 Comments
Disqus
Fb Comments
Comments :

0 comments:

Post a Comment