How to Hide and Collapse Google AdSense Ad Unit Instead of Showing Public Service Ad (PSA)

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>


One Response to “How to Hide and Collapse Google AdSense Ad Unit Instead of Showing Public Service Ad (PSA)”

  1. Guru of Search
    March 10th, 2009 04:26
    1

    I like the idea of a collapsing script – but is this in line with Google’s TOS?

Leave a Reply

You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Subscribe to comments feature has been disabled. To receive notification of latest comments posted, subscribe to My Digital Life Comments RSS feed or register to receive new comments in daily email digest.
Custom Search

New Articles

Incoming Search Terms for the Article

hide ad on 2.0 - hide ad for 2.0 - google adsense a button to hide ads - google ad sense js - how to hide google ads - google free ads url - adsense hide url - google ads collapse - hide ads javascript - hide public service ads by google - adsense ad next previous buttons hide - google adsense do not show empty advertisement - Hide advertisement on 2.0 - how to hide from google - collapsing blank space in adsense - manage adds > does not show active adsense units - google_adsense_script - hide ad on 2.0 - how to hide rapidshare links in adsense unit - js button hidden ads google - collapse text ads by google - google ads javascript in internet explorer - hide codes with no ad - hide and collapse - hide the ad for 2.0 - hide my ip from adsense - hiding adsense ads - hide adsense ad under image - how to hide googles translation frame on website using javascript - how to hide adsense from main page - Javascript to hide google adsense - why do google ads flash on and then disappear - adsense link unit ad code - Collapsing ad units in blogger - hide ip works for adsense - The requested URL /google_adsense_script.html was not found on this server. - what is the code to hide advertisements - ad units display same contents - adsense unused ad units - adsense ad code server - google ad services returns html body transparent - google adsense ad servers - how to hide adsense on certain ip in blogger - how to hide google pub id - show non-google ads - Websites where I can hide advertisements - adsense ad does not collapse - google adsense showing blank - google adsense is blank - how to hide google custom search -