How to Add AdSense Backup Ads Since Feature Was Removed From Adsense?

I have a new site with an initial articles posts. Before adding any articles I want finalize a plan for banners. My site is hosted on Blogger but uses a custom Google .com domain.

I was immediately approved for AdSense; however, there is a major sticking point with that service. Adsense previously allowed users to indicate a backup ad to be served if AdSense could not fill the space. That preference has been removed. When ads are not shown AdSense either shows a blank space the same size as the ad or nothing.

That leaves figuring out a way to use javascript or other code to determine if an ad is actually being shown to a user and if not use a backup ad.

I have a test html division to show AdSense banner on the bottom of each post. The problem that there appears to be no way to detect if an ad is actually shown to a user.

If you place the code at the bottom of this thread just above the closing body tag in attempt to deliver an alternative ad it will fail. This is because Adsense servers are sending the same code to the division regardless of if an ad is actually shown, a blank space is shown, or nothing is shown. In the later two cases Adsense code simply does not retrieve the required information to actually render the ad. I believe this is intentional on the part of Google to prevent you from serving any backup ads at your end via code.

If you add this script just above the closing body tag it will show the same type of innerHTML regardless of whether the ad was shown or not. There is nothing in the code delivered to the division by Adsense that you could use as a trigger to detect if an ad was actually shown


How do I deal with this? I can’t have large blank areas on my site that make it look bad. I also can’t waste space for non performing ads.

<script type='text/javascript'>

// Run when the DOM content is loaded
    // AdSense ads lazy load, so they can't be examined right away
        // Search the DOM for ad slots assuming they all have <div class=adsenseads> around them
        var x=document.getElementsByClassName("adsenseads")
        for(var i=0;i<x.length;i++){
            // See if adsense loaded an ad by checking for an iframe
                // No ad loaded         
                x[i].innerHTML="BACKUP AD CONTENT HERE";
    },3000); // 3000ms or 3 seconds


This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.