Google AdSense is probably the advertising network that has the highest fill rate for each and every ad space inventories available, be in for US, North America or Europe based visitors or international traffic. However, it’s still possible that Google AdSense crawler scans the page, and does not find any relevant ads to display. When no ad is targeted in an ad unit, Google AdSense Public Service Ad, commonly known as PSA is shown instead, unless an alternate ads URL is specified.

For webmasters, bloggers or publishers who don’t have any alternative ads to show, do not want to fill in the ad space with a solid color (with google_alternate_color JavaScript variable), and do not want website visitors to see any public service ads (which is non-paid anyway), Google AdSense offers another choice, that is collapsing ad unit.

According to AdSense Help, collapsing ad units are an optional advanced feature of alternate ads – the collapsing ad unit code will ‘collapse’ your ad unit so that it takes up no page space if there are no targeted ads available. This allows you to minimize any blank, unused, or not monetizing space that would otherwise occur through the use of alternate colors.

Note that the collapsing ad unit only work on website that hosted on its own domain name or subdomains on its own server that allows remote or console access (also possible via FTP or SFTP, Telnet or SSH). The reason is because a script file has to be uploaded and hosted on the a location of each domain and sub-domain, which will be referenced and called by alternate ad URL to implement the collapsing ad unit. So users of Blogger or blogspot.com (unless hosted on an external server or previously upgraded to Blog*Spot Plus), WordPress.com, Blogsome.com and etc. probably out of luck.

To implement the collapsing ad units feature, follow the instructions below:

  1. Download the collapsing ad units file by right-clicking the link below and selecting ‘Save Target as…’: google_adsense_script.html.
  2. Copy or upload google_adsense_script.html to any location on a domain to implement the collapsing ad unit. The location is not important as long as it’s on the same domain with the webpages with the ad unit to hide when no ads. For multiple domains or subdomains, the HTML file is required for each of them in order for collapsing ad unit to work.

    For example, www.mydigitallife.info can host the HTML for all web pages under www.mydigitallife.info, but not www.tipandtrick.net, nor forums.mydigitallife.info will work.

  3. Login to Google AdSense account.
  4. For existing ad unit, click on AdSense Setup, and then Manage Ads. Edit Ad Settings of the ad unit to implement the collapsing on no ad feature. Under “More options” section, select the Show non-Google ads from another URL radio button, and enter the fully defined path to the collapsing ad units HTML file on your domain. No change of code necessary.

    Google AdSense Collapsing Ad Unit

    For new ad code, click on AdSense Setup, and then Get Ads. Click on AdSense for Content, and then select the Show non-Google ads from another URL radio button under the “More options” section, and enter the fully defined path to the collapsing ad units HTML file on your domain. Copy and paste the ad code into the web page to implement Google AdSense.

    For publisher using classic legacy Google AdSense ad code, add a new JavaScript variable named google_alternate_ad_url to the Google AdSense ad unit ad code which wants to make a hiding ad unit when no targeted ads. For example,

    google_alternate_ad_url = “http://www.mydigitallife.info/scripts/google_adsense_script.html”

After adding the alternate URL which points to the collapsing script on the AdSense ad code, ad units will disappear when targeted ads are not available. When visitor is using Internet Explorer version 5.0 or lower – any unused ad units will appear as empty, transparent boxes.

For user who can’t upload or transfer the HTML file to the web server, but has console access and able to SSH or Telnet into the host, just create a new google_adsense_script.html via vi on the server’s web root directory, and then copy and paste the following content:

<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN”
“http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd “>
<html xmlns=”http://www.w3.org/1999/xhtml” xml:lang=”en” lang=”en”>
<head>
<meta http-equiv=”Content-Type” content=”text/html; charset=iso-8859-1″ />
<title></title>
<script src=”http://pagead2.googlesyndication.com/pagead/google_adsense_script.js” type=”text/javascript”></script>
</head>
<body style=”background-color: transparent;”>
</body>
</html>

Related Posts