How to Create a Clickable Affiliate Ad as a Backup for an AdSense Unit

Sometimes an AdSense unit won't display an ad to a user for whatever reason. When an AdSense unit doesn't show an ad, it leaves an odd amount of space within the content, and reduces my ability to monetize those pages – and I find that unacceptable.

This used to be a much more significant problem, but in the age of remarketing, AdSense can usually find an ad to display for a user even if your particular page content doesn't have a good content specific match for one. But, sometimes an ad still won't show, so I still define a backup ad for my AdSense units.

AdSense offers up the ability to specify what you want to show in the place of an AdSense unit that doesn't display an ad for whatever reason when you create an AdSense unit. The drop down offers you the option to decide whether you want to show a blank space, a solid color or a backup ad when AdSense fails to display. However, you'll note that choosing the backup ad option only offers you the ability to enter the URL of the backup ad that you want to show.

Backup AdSense Unit Option

Being presented with the option of entering only a single URL leads most people to believe that they can specify the URL of an image to show, but can't make that ad image clickable. However, you can create a clickable ad to show in place of AdSense. AdSense simply does a really poor job of making it obvious that you can do so.

What you would typically expect to see in a scenario like this would be two fields – one to specify the URL of the image to show and another to specify the URL the image should link to. I don't get why AdSense doesn't make the process of defining a clickable backup ad more intuitive, but it is what it is.

Create the code to define a clickable backup ad

To create a clickable backup ad, AdSense requires you to create an HTML page on your website that contains the ad in HTML format. To create your backup ad, copy and paste the code below into your favorite text editor.

(Note for beginners – Microsoft Word is not a text editor. On Windows you can use the native Notepad application; on Mac you can use Textedit, providing you change the default formatting. Personally, I use Textmate for Mac.)

<html>
<head>
<title></title>
</head>
<body>
<a href="YOUR AFFILIATE LINK" target="_top"><img src="YOUR AD IMAGE"></a>
</body>
</html>

Replace YOUR AFFILIATE LINK with the URL the ad should link to. Then replace YOUR AD IMAGE with the URL to the ad creative you want displayed. For example, below is the code I use to generate a SEMrush ad as my backup AdSense ad for the Sugarrae site.

<html>
<head>
<title></title>
</head>
<body>
<a href="https://sugarrae.com/getit/semrush-adsense" target="_top"><img src="https://sugarrae.com/wp-content/uploads/2016/03/semrush-banner-3.jpeg"></a>
</body>
</html>

Google recommends that you use absolute URLs like I did in the example above. Also, note that the target=”top” element in the link code needs to be there, or your ad will not display correctly. You should also be sure that the creative you plan to use for your ad is the same size as the AdSense unit you're making it the backup for.

Once you've copied the code into your text editor and edited it to include your affiliate link and affiliate banner, you need to save the file with a .html extension. Click Save, name the file whatever you'd like – I called my file semrush-backup-ad.html – and save it in HTML format. On Notepad, you'll need to manually enter the .html after the file name when saving. With TextEdit, you can choose to save it as an HTML file in the File Format drop down.

Upload your HTML file to a server

Now that you have the HTML file for your backup ad created, you'll need to upload it to a server. AdSense doesn't care where you host the file, as long as the file is accessible on the Internet. I uploaded it to the Sugarrae site via FTP (you can see my ad here). If you're unsure of how to upload an HTML file to your website, you'll need to contact your host for help.

Adding the backup ad to your AdSense unit

To add the backup ad to your AdSense unit, log into AdSense and click on My Ads. Click on the name of the AdSense unit you want to specify the backup ad for – not the Edit Ad Type option. On the next screen, locate the Backup Ads field and choose the Show other ads from another URL option on the drop down.

Choose backup ad option for the AdSense unit

The enter the URL of the HTML file you created and uploaded to your host using the steps above and click Save.

Enter the URL of the backup AdSense ad

The affiliate advertisement you've created is now the default backup ad that will display in that AdSense unit should an official AdSense ad fail to show for whatever reason.

Advanced tip: Whenever possible, you should use an affiliate link that has SID tracking within your backup ad so that you can ascertain both the number of clicks that ad generates, as well as if the ad makes any sales. If you're cloaking your affiliate links like I do, you'll want to ensure you create a new cloaked link for the backup AdSense ad so that you can track clicks for it – especially helpful if the affiliate program doesn't support SID tracking.

Unfortunately, the SEMrush affiliate program does not offer the ability to add SID tracking to their links, so I had to use my general affiliate link in the example above. But I'll at least be able to see how many clicks the link generates via my link cloaking plugin, Pretty Link Pro (affiliate).

Testing your backup AdSense ad

Since AdSense has made defining a backup ad a bit complicated, here's where I should be giving you a link to test that you've created your backup ad correctly. Unfortunately, Google doesn't provide a way to test backup AdSense ads – which makes no sense, but once again, it is what it is. All you can really do is follow the instructions to the letter and hope for the best.

You can also view your server logs to see if the backup ad you created is being accessed and monitor the number of clicks on the specific affiliate link you used within the ad – providing you used an SID code for the link or are using a unique link via a cloaking plugin that tracks clicks.

Note: It can take some time after adding the backup ad for it to start working within the ad unit.

Rae

Rae Hoffman aka "Sugarrae" is a veteran digital marketer and SEO consultant. She is also a serial entrepreneur. You can find out more about her entrepreneurial efforts here. Rae is most active on Twitter.

8 Comments

  1. Stewart on April 6, 2016 at 2:17 pm

    Thanks for this really helpful tip and for providing the code Rae. It is kind of frustrating not to have relevant AdSense ads; it is kind of demeaning to your site. I am glad you shared this insight and helped us to make better Ad sense.



    • Rae on April 12, 2016 at 5:24 am

      You’re welcome Stewart!



  2. Dev Patel on April 21, 2016 at 1:17 am

    Interesting. I assume adding javascript and rotating banners will not hurt either.

    UC browser and opera mini blocks ad automatically. In such case, will it be able to show custom ads by us?



    • Rae on April 21, 2016 at 8:22 am

      The backup ad is still served by Adsense, so if something is blocking AdSense, to my knowledge it will still block the backup ad.



  3. Ben on May 19, 2016 at 9:55 am

    Thanks, Rae. I’ve never known how to use this and I appreciate the detailed instructions. I’m going to put some backup ads in place and it will be interesting to see how often they actually appear.

    Question: do you know how this would work with their responsive ads?



  4. Glory on April 4, 2017 at 12:46 am

    Thanks for explaining in detail. I am going to use this for my adsense ads.



    • Rae on May 7, 2017 at 10:08 am

      You’re welcome!



  5. Connie on December 13, 2017 at 7:49 pm

    I have the same question…..what about responsive ads? I’ve pretty much switched all of my ad units to them.

    Thanks