Code outside the body
Pasting the unit code outside the body tags stops ads from displaying properly.
Implementation guide
Display ads
The classic AdSense ad: a rectangle or a strip that you place wherever you want and that can adjust itself to the screen size.
Understand it in 1 minute
The display ad is the best-known AdSense type. Think of a poster hanging on the school wall: it stays in a fixed place and everyone passing by can see it. On a site it is the same. You choose a space on the page, paste a piece of code there, and Google places an ad in that space.
There are two ways to create this ad. The first is responsive, which is what Google recommends. It works like water in a glass: it takes the shape of the space where it was placed. If the person opens the site on a computer, tablet or phone, the ad works out the right size by itself. If the person rotates the phone, a new ad of the right size is loaded. The second way is fixed, where you choose the exact width and height, for example 300 by 250 pixels. Google warns that with a fixed size there may be fewer ads available, and this can reduce earnings.
The sizes Google points to as the best performing are 300x250 (medium rectangle), 336x280 (large rectangle), 728x90 (leaderboard), 300x600 (half page) and 320x100 (large mobile banner). With the phone held upright, the responsive ad can stretch and take up the full width of the screen, because Google's tests showed it performs better that way. This only happens when the system thinks it will give a good result and a good experience for visitors.
The display ad is worth using when you want to decide with your own hands where each ad shows, for example at the top of the article or beside the text. Just remember that the chosen place must follow Google's placement rules: the ad cannot be disguised as content, you need care not to leave it right next to menus or buttons, and the screen cannot have more ads than content.
Step by step
Implemented example
<script async
src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-0000000000000000"
crossorigin="anonymous"></script>
<!-- Anúncio de display responsivo -->
<ins class="adsbygoogle"
style="display:block"
data-ad-client="ca-pub-0000000000000000"
data-ad-slot="1234567890"
data-ad-format="auto"
data-full-width-responsive="true"></ins>
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script>
<!-- Versão de tamanho fixo (728x90) -->
<ins class="adsbygoogle"
style="display:inline-block;width:728px;height:90px"
data-ad-client="ca-pub-0000000000000000"
data-ad-slot="1234567890"></ins>
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script>What Google recommends
Tips
Watch out
Pasting the unit code outside the body tags stops ads from displaying properly.
If the responsive ad sits in a box with no defined width, such as a floating element, it cannot work out the size. Set the width with CSS media queries.
A box with a fixed or limited height disrupts the responsive ad. Google recommends avoiding this.
Scripts that run before the ad and hide parts of the page can stop the size calculation. The recommended fix is to set the size with CSS media queries.
Google recommends responsive. Fixed may have fewer ads available, which can reduce earnings.
Usually a few minutes, but it can take up to an hour.
The policy does not set a number. The rule is that the screen must not have more ads than content, and Google reminds you that less can be more.
Yes. When the screen changes orientation, a new ad of the right size is loaded. The previous one is kept and comes back if the person rotates the phone again.
Yes. Google's help shows how to use CSS with display none to hide the unit at a screen width. Hidden this way, the ad is not even requested.
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.