Is there a way to resize google adsense in a responsive design?

Rick Smith picture Rick Smith · Aug 28, 2012 · Viewed 15.7k times · Source

I'm using google adsense in my responsive wordpress design (that's using twitter bootstrap.) Right now when the site resizes the ads stick far out, and just look bad.

Is there anything I can do to help with this? I actually saw a site that looked like it was someone resizing the ads on smaller screens...I'm not sure how this is possible since it's java script, right?

Any feedback would be very helpful. Thanks!

Answer

0b10011 picture 0b10011 · Aug 29, 2012

Ideally, CSS media queries could automatically scale the ads down, and, in a perfect world, the ads would automatically change their layout based on the new size. However, Google Ads do not support this, nor do they even allow this—you aren't allowed to change the contents of the ad, nor hide any portion of it, except with explicit permission from Google, according to their Terms of Service (removed text marked with [...]):

5. Prohibited Uses. You shall not, and shall not authorize or encourage any third party to: (i) [...] (ii) edit, modify, filter, truncate or change the order of the information contained in any Ad, Link, Ad Unit, Search Result, or Referral Button, or remove, obscure or minimize any Ad, Link, Ad Unit, Search Result, or Referral Button in any way without authorization from Google; [...]

An alternative solution would be to serve up the ads via JavaScript on a conditional basis. For example, when the page loads, retrieve the size of the browser's viewport and if the width of the viewport of the browser is smaller than the width of the preferred ad, serve up a smaller ad instead. It should work similar to CSS media queries, except do not serve up new ads when the user resizes their browser, as this would generate false impressions (multiple impressions on a single page, without refreshing), which is also against their Terms of Service:

5. Prohibited Uses. You shall not, and shall not authorize or encourage any third party to: (i) directly or indirectly generate queries, Referral Events, or impressions of or clicks on any Ad, Link, Search Result, or Referral Button (including without limitation by clicking on “play” for any video Ad) through any automated, deceptive, fraudulent or other invalid means, including but not limited to through repeated manual clicks, the use of robots or other automated query tools and/or computer generated search requests, and/or the unauthorized use of other search engine optimization services and/or software; [...]