Responsive Web Design
| |

How to create responsive adsense code

Google’s program policies do not allow you to modify your Adsense code which artificially inflates ad performance or harms advertiser conversions. In most cases, you’ll want to copy paste the code exactly as you get from the generator.

However, most sites today are going responsive and you’ll want to ensure that you use the correct size ads when your visitor is viewing your blog from a mobile device. Now, Google has modified the policy that allows you to modify the code for a responsive design.

Responsive Web Design

Responsive adsense code

Check out the example code below courtesy Google’s help center article:

[code language=”javascript”]
<script type="text/javascript">
google_ad_client = "ca-publisher-id";
width = document.documentElement.clientWidth;
google_ad_slot = "1234567890";
google_ad_width = 320;
google_ad_height = 50;
if (width > 500) {
google_ad_slot = "3456789012";
google_ad_width = 468;
google_ad_height = 60;
}
if (width > 800) {
google_ad_slot = "2345678901";
google_ad_width = 728;
google_ad_height = 90;
}

</script>
<script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
[/code]

Have you implemented responsive adsense code yet?

[Image source: What The Heck Is Responsive Web Design?]

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.