Sign in

AdSense Help



Alternate Ads Guide

By default, if no targeted ads are available, public service ads (PSAs) will be shown on your page. However, our alternate ads feature allows you to utilize your ad space in the manner you choose in the event that we're unable to serve targeted ads to your page. By specifying a color, image, HTML page, or ad server of your choice, you can make sure that your advertising space is always being used effectively. You can specify any of the following as an alternate ad:

  • Color: you can enter any hexadecimal color code (or just use our simple color picker!) to replace PSAs. You can essentially make your ad block 'disappear' by matching the alternate ad color to the background color of your page
  • Image: you can use any image as your alternate ad
  • HTML page: this is useful if you'd like to implement a clickable image as your alternate ad. The HTML page will contain the information required to load your image and link it to any destination
  • Collapsing ad units: more advanced version of the alternate ad color described above, the collapsing ad units code will shrink your ad units instead of showing PSAs. This means that your page won't have blank areas that may occur with alternate ad colors, as the content around the ad unit will shift up to fill the empty space.

Each of these options is described in more detail below. Please be aware that you may not specify Google ads as your alternate ads.

Color

Let's start with the easiest option – substituting PSAs with a solid color that matches the background of your site. To set an alternate ad color, go to the AdSense Setup tab within your account. When choosing more options for your ad code, click the Fill space with a solid color radio button in the alternate ad or color section to pop up a color palette.

Select your desired color from the palette and click Save and get code – your alternate ads text box will be updated with the hexadecimal color code. Now click Continue to add your color selection to the ad code.

Back to top

Image

Another simple way to take advantage of alternate ads is the use of static images. If you'd like to use an image as your alternate ad, click the Show ads from another URL radio button and enter the fully defined URL of the image in the Alternate ad text box. A fully defined URL is one that includes the http:// and ends with the image filename. For example:

http://www.google.com/logos/Logo_60wht.gif

When you're creating the image to use as an alternate ad, make sure that the dimensions are the same as the ad format that will display it. If your image is bigger than the ad format, the image will be cropped at the right and bottom edges. So, if you're creating an alternate ad image for a 240x120 ad format, make sure that your image is also 240 pixels by 120 pixels.

Click Continue when you've entered the URL into the alternate ads text box. This will add your selection to the AdSense code to be copied.

Back to top

HTML Page

Using an HTML page as your alternate ad is most useful for creating a 'clickable image' ad. You'll specify the path to an HTML page that contains the information necessary for loading the image, as well as the link code.

There are 2 steps involved in setting an HTML page as your alternate ad: creating the HTML page, and specifying it as your alternate ad.

  1. Creating the HTML page

    You'll need to create a simple HTML page that loads your desired image, and contains the hyperlink code. There are a few tricks to successfully creating this code:

    • Use absolute URLs: we suggest using absolute URLs when you're coding this HTML page. An absolute URL is one that includes the entire, fully-defined path. This ensures that you won't run into any errors when placing the code on various pages of your site.
    • Use target="_top": this code tells your browser which window to use when loading the destination page of your clickable image. If you don't include this tag in your code (and we'll show you where to include it below) your browser will try to load your destination within the ad format itself.

    We've included a sample HTML page below. Note the absolute URLs, as well as the target="_top" tag.


  2. Specifying the HTML page as your alternate ad

    Once you've created and saved your HTML page, you'll need to upload it to your server. This page can be hosted anywhere online, as long as it's accessible from the internet.

    In the alternate ads text box, simply enter the fully defined path to the saved HTML page. For example:
    http://www.example.com/docs/alternatead.html

    Click Continue to add your alternate ad selection to the code in your publisher account.

Back to top

Collapsing ad units

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 space that would otherwise occur through the use of alternate colors.

To implement the collapsing ad units feature, you'll need to host a small HTML file on your domain. Your alternate ad URL will reference this file, which will be called if there are no ads available for that particular ad unit. Please follow the instructions below:

  1. Download the collapsing ad units file by right-clicking the link below and selecting Save Target as...

    http://pagead2.googlesyndication.com/pagead/google_adsense_script.html

  2. Copy this file to any location on your domain. Important: if you are running ads on multiple domains or subdomains, you will need to host this file on each of your domains and subdomains in order to use the collapsing ad units feature.
  3. In the Alternate Ads URL text box, enter the fully defined path to the collapsing ad units HTML file on your domain. For example: http://www.example.com/scripts/google_adsense_script.html
  4. Click Continue.
  5. Copy and paste the ad code into your webpages. You must ensure that the alternate ad references the collapsing ad units script on the same domain or subdomain as your webpage. For example, if your alternate ad URL references the collapsing ad units HTML file on www.example2.com, you cannot place this ad code on any page of www.example.com or on any page of forums.example2.com. Doing so will result in errors on your page.
If you have successfully implemented the collapsing ad unit code, your ad units will disappear when targeted ads are not available. Please note that this feature will not work with Internet Explorer version 5.0 or lower – any unused ad units will appear as empty, transparent boxes.

Back to top


Tell us how we're doing: Please answer a few questions about your experience to help us improve our Help Center.