Responsive Adsense Code


/ Published in: JavaScript
Save to your folder(s)

If you're using Adsense on responsive design, this is the code that you can use and it's NOT against its TOS.


Copy this code and paste it in your HTML
  1. <script type="text/javascript">
  2. google_ad_client = "ca-publisher-id";
  3. width = document.documentElement.clientWidth;
  4. google_ad_slot = "1234567890";
  5. google_ad_width = 320;
  6. google_ad_height = 50;
  7. if (width > 500) {
  8. google_ad_slot = "3456789012";
  9. google_ad_width = 468;
  10. google_ad_height = 60;
  11. }
  12. if (width > 800) {
  13. google_ad_slot = "2345678901";
  14. google_ad_width = 728;
  15. google_ad_height = 90;
  16. }
  17. </script>
  18. <script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
  19. </script>

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.