“responsive” ads with adsense


Google recently implemented a responsive ad block that essentially performs some media queries and returns the appropriate ad unit depending on screen size. My sample code block looks like:

Previous Post

I recently switched to a “responsive” web design and couldn’t find a good way to dynamically show the proper adwords ad format depending on the viewport of the visitor’s device. This snippet uses jquery to determine viewport width and then sets the appropriate ad channel variables for show_ads.js:

UPDATE: Today (May 23 2013) Google announced its now ok to modify the adsense code like I mentioned above (Woops! didn’t know I was breaking TOS)

You can read their post announcing the changes here. The relevant code snippets they provide for sites using responsive web designs looks pretty much identical to mine (minus the pointless reliance on jquery):

More details can be found on the help pages for adsense advertisers located here.

Lower Your Bounce Rate With One Line of Code

While reading through the Google Analytics Event Tracking Guide, I came across this nugget:

In general, a “bounce” is described as a single-page visit to your site. In Analytics, a bounce is calculated specifically as a session that triggers only a single GIF request, such as when a user comes to a single page on your website and then exits without causing any other request to the Analytics server for that session. However, if you implement Event Tracking for your site, you might notice a change in bounce rate metrics for those pages where Event Tracking is present. This is because Event Tracking, like page tracking is classified as an interaction request.

Of course having read through several SEO related posts identifying bounce rate as a ranking factor (or at a minimum a quality signal), I devised a way to game it.

<div id="header" onMouseOver="pageTracker._trackEvent('bounce', 'bouncecheck', 'Look Ma No Bounce');">

I figure a mouseover on my header will probably be triggered enough to dramatically drop my bounce rate without looking too artificially manipulated. Plus I wonder if a body onLoad statement would be overkill, or trigger faster than the gif request. Anyway after implementing this for one day you can see the huge difference below.

Now while my method is obviously solely aimed at gaming the system, there are some legitimate uses. A few examples that come to mind where firing off an event make sense are video plays, if the end of a javascripted animation, newsletter signups, rss subscribes and there are probably a thousand more.