Open workspace

Implementation guide

Anchor ad

Anchor ads

An ad strip that stays stuck to the top or bottom of the screen while the person scrolls the page, and that can be closed easily.

  • AdSense
  • Ad Manager
  • mobile and desktop
Desktop
Mobile

Understand it in 1 minute

What the anchor ad is

The anchor ad is an advertising strip that stays stuck to the edge of the screen. Think of a fridge magnet: the door opens and closes, but the magnet stays in the same place. Here it is the same. The person scrolls the text up and down, and the strip stays still at the top or bottom of the screen. It sits on top of the page.

In AdSense, the anchor is part of Auto ads, in the group called overlay formats. Overlay means the ad sits on top of the page. Google explains that, by default, the anchor appears at the top of the screen and moves to the bottom when staying at the top would get in the person's way. The top one only appears after the person scrolls enough, so it never covers the site name or the menu. There is also the dynamic anchor, which can get bigger, shrink or move to a small corner of the screen as a small ad.

In Ad Manager, the anchor is handled by GPT, the Google Publisher Tag, which is the Google code that requests and displays ads on the page. You request a slot, which is the ad space, of the top anchor or bottom anchor type. GPT itself creates the ad box, so you do not need to design a space on the page. If the page or the device does not support this format, GPT does not create the slot.

Google says anchor is a high-performance format that follows the Better Ads Standards, which are rules so ads do not bother readers. The person can close the ad at any time by clicking the little arrow. On mobile and desktop, Google recommends requesting the anchor only on the pages where you want it to show. If the same code goes to both, it is worth defining when and where each one shows the anchor.

Step by step

How to implement

  1. Put the code on every pageIn AdSense, Auto ads work with a single code placed on all pages of the site. In Ad Manager, the page needs to load GPT.
  2. Turn on the anchor in AdSenseClick Ads and then Edit next to the site. Under Ad settings, turn on Auto ads. Under Overlay formats, keep Anchor ads turned on. Then click Apply to site.
  3. Choose the position and screensIn the advanced settings, use Select anchor ad position: At the top or bottom, Top only or Bottom only. The options for dynamic anchors and for screens wider than 1,000 pixels are also there.
  4. In Ad Manager, create the anchor slotIn GPT, define an out-of-page slot of the top anchor or bottom anchor type, preferably inside the head. Then check that it did not come back empty.
  5. Prepare the inventory in Ad ManagerCreate or reuse ad units with the 320x50 size and the other traditional sizes. In reserved line items, you can target by the anchor inventory format.
  6. Test without changing the codeOn any page that already loads GPT, add the demo code shown in the example to the end of the address to see a test anchor.

Implemented example

The code and how it looks on screen

Both blocks go in the head of the page: the first is for those who use AdSense and the second for those who use Ad Manager with GPT; use only the one for your product.
<!-- AdSense (opcional): âncoras só no rodapé -->
<script async
  src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-0000000000000000"
  data-overlays="bottom"
  crossorigin="anonymous"></script>

<!-- Ad Manager (GPT): slot âncora -->
<script async
  src="https://securepubads.g.doubleclick.net/tag/js/gpt.js"
  crossorigin="anonymous"></script>
<script>
  window.googletag = window.googletag || { cmd: [] };
  googletag.cmd.push(() => {
    const anchorSlot = googletag.defineOutOfPageSlot(
      "/1234567/exemplo",
      googletag.enums.OutOfPageFormat.BOTTOM_ANCHOR // ou TOP_ANCHOR
    );
    // Volta null se a página ou o aparelho não aceitar âncora
    if (anchorSlot) {
      anchorSlot.addService(googletag.pubads());
    }
    googletag.enableServices();
    if (anchorSlot) {
      googletag.display(anchorSlot);
    }
  });
</script>

<!-- Teste: https://www.exemplo.com/#gamTopAnchorDemo
     ou #gamBottomAnchorDemo -->
On desktopOn a computer, the anchor appears as a strip stuck to the top or bottom of the screen. In AdSense, an option allows or blocks anchors on screens wider than 1,000 pixels.
On mobileOn mobile, the strip stays stuck to the top or bottom while the person scrolls. The dynamic version can take up more space, and the person can shrink it on the spot to the normal size.

What Google recommends

Do and don't

Allowed

  • Let Google choose between top and bottom, or choose top only or bottom only in the advanced AdSense settings.
  • Change the AdSense code with the official parameter to show anchors only at the bottom, or only regular anchors at the bottom, without the collapsible version. Google calls these changes permitted modifications.
  • Show anchors on mobile, tablet and desktop, as long as you request the ad only in the places where you want it to appear.
  • In Ad Manager, target line items by the anchor inventory format and compare performance with the Inventory format dimension.
  • Measure the result in AdSense with a custom report filtered by the Anchor ad format.

Not allowed

  • Do not send the same code to mobile and desktop without deciding where each should have an anchor, and do not request an anchor on pages where you do not want an ad.
  • Do not run GPT inside an iframe: the anchor only works when GPT is in the main window.
  • Do not change the AdSense code beyond the modifications Google accepts, and do not make the ad slide, zoom or draw too much attention.
  • Do not encourage clicks on the ad, neither with phrases asking for a click nor with arrows pointing to it.

Tips

To do it right

Watch out

Common errors

Not checking whether the slot came back empty

GPT returns null when the page does not support anchors. If the code does not check for this, it tries to use a slot that does not exist.

Page not adjusted for mobile

The anchor needs a mobile-optimized page, with neutral zoom. This is usually solved with the viewport tag in the head.

Calling display too early

With single request architecture (SRA), the first display request asks for all slots defined before it. If it comes before the fixed spaces exist on the page, ads are left out. Google recommends delaying that first call.

Thinking the anchor is turned off

Anyone using the bottom parameter in the AdSense code turns on the anchor even with the option off in the dashboard. To really turn it off, remove the parameter too.

Frequently asked questions

Does the anchor appear on a computer?

It can. In AdSense it works mainly on mobile, but also on a computer, and you control this with the option for screens wider than 1,000 pixels.

Can the person close the ad?

Yes. Google says the anchor is easy to dismiss, and in Ad Manager the person can close it at any time by clicking the arrow.

Do I need to create a div for the anchor in Ad Manager?

No. The anchor creates its own box. You only define the slot in GPT.

Can the anchor have video in Ad Manager?

Yes. Out-of-stream video (not in-stream) is on by default, and the Block non-in-stream video ads protection must be turned off.

Library

Official Google source

Everything on this page follows Google's official documentation. Read it straight from the source:

Does your site use this format the right way?

The audit reads the site as a visitor would, without clicking anything, and shows what to fix.

Run an audit