Different div name
The name passed in the slot definition and in the display must be the same as the div's. When it is not, the ad simply does not appear.
Implementation guide
Display ad slots (Google Publisher Tag)
The classic Ad Manager ad space, created with the Google Publisher Tag, with a fixed size, several sizes or responsive.
Understand it in 1 minute
The Ad Manager display ad is the ad rectangle that sits still inside the page: in the middle of the text, at the top or on the side. Think of a poster hanging on the school wall. It has a set place and a set size, and everyone who walks by can see it. In Ad Manager, this reserved place is called a slot, which is just the English word for ad space. The one that requests and shows the ad in this space is GPT, short for Google Publisher Tag, a Google code library that you add to your site.
It works like this: first you tell GPT which Ad Manager ad unit to use, which sizes fit there and in which box of the page it should appear. This box is a div, a piece of HTML with a unique name. Then GPT requests the ad and draws it inside the box. The box name must be the same in both places. If it is not, the ad does not show. Google itself tells you to check this when the ad does not show.
The size can be chosen in three ways. With a fixed size, only ads of that measurement come in, such as 300 by 250. With multiple sizes, you list several measurements and Ad Manager can pick any of them. With responsive, you build a table called size mapping, which says which measurements apply for each screen width: one list for large screens and another for small screens. There is also the fluid size, which stretches to the page width, but Google explains that today it is used only for native ads.
Google created this way of working so the site has control: you decide where each ad lives, which sizes it accepts and when it loads. The documentation teaches you to let the ads at the bottom of the page load only when the person gets close to them, which is called lazy loading. It also explains how to refresh an ad without reloading the whole page, following timing and disclosure rules. The display ad is worth using when you already have an Ad Manager account and want to carefully choose the place and size of each space.
Step by step
Implemented example
<!-- No <head> -->
<script async
src="https://securepubads.g.doubleclick.net/tag/js/gpt.js"
crossorigin="anonymous"></script>
<script>
window.googletag = window.googletag || { cmd: [] };
googletag.cmd.push(() => {
// Tamanhos por largura de tela (slot responsivo).
const mapping = googletag
.sizeMapping()
.addSize([1024, 768], [[728, 90], [300, 250]])
.addSize([0, 0], [300, 250])
.build();
googletag
.defineSlot(
"/1234567/exemplo",
[[728, 90], [300, 250]],
"banner-exemplo",
)
.defineSizeMapping(mapping)
.addService(googletag.pubads());
// Carregamento lento para espaços longe da tela.
googletag.setConfig({
lazyLoad: {
fetchMarginPercent: 500,
renderMarginPercent: 200,
mobileScaling: 2.0,
},
});
googletag.enableServices();
});
</script>
<!-- No <body>, onde o anúncio deve aparecer -->
<div id="banner-exemplo" style="min-height: 250px;"></div>
<script>
googletag.cmd.push(() => {
googletag.display("banner-exemplo");
});
</script>What Google recommends
Tips
Watch out
The name passed in the slot definition and in the display must be the same as the div's. When it is not, the ad simply does not appear.
Google asks that the width, height and div name match what is in the tag. If they do not match, the ad may not show.
Without an active line item with Ready status, your own inventory does not show an ad, even with the right code.
In Google's example, screens smaller than 640 by 480 get an empty list and end up with no ad. If you copy it without adjusting, phones held upright can end up with no banner.
With multiple sizes, any measurement in the list can appear on any screen. With responsive, the size mapping says which measurements apply for each screen width.
Google explains that today the only fluid type Ad Manager accepts is the native ad. For a regular banner, use a fixed size, multiple sizes or mapping.
On the web, refresh by time or by event needs at least 30 seconds. Refresh by the person's action has no minimum. In all cases, it must be declared in Inventory rules.
Google recommends deferring spaces below the fold, which helps mainly on mobile, where resources are smaller. Spaces at the top should get priority.
Library
Everything on this page follows Google's official documentation. Read it straight from the source:
The audit reads the site as a visitor would, without clicking anything, and shows what to fix.