GPT inside an iframe
IMA for HTML5 only recognizes GPT spaces on the main page. In an iframe, without the proxy script, the companion does not appear.
Implementation guide
Companion ads
A banner that appears on the page at the same time as a video or audio ad plays in the player, forming a pair.
Understand it in 1 minute
Think of a concert: while the singer is on stage, a screen beside her shows the song name. Both tell the same story at the same time. The companion ad is like that. While the video or audio ad plays in the player, a banner of the same ad shows in an ad slot on the page, near the player.
Google explains that companion ads let you show ads in display spaces at the same time as an ad is served in a video or audio player. They always depend on the main ad, called the master: without a master, there is no companion. It is like the concert screen, which only makes sense if someone is singing. A VAST ad can carry up to 6 companion display ads.
How does the site do this? The display slots next to the player are created with GPT, the Google Publisher Tag, which is Google's code for ad slots. GPT has three pieces for this. The first, companionAds, says that the slot can receive a companion when a VAST ad is playing in a player on the same page. The second, setRefreshUnfilledSlots, asks to fill the slots that stayed empty later. The third, enableVideoAds, makes GPT and the IMA SDK use the same correlator, a number that is the same in all ad requests of the same page view. On the player side, IMA sends the companion sizes in the ciu_szs parameter of the tag.
When is it worth it? When you have video or audio ads and want the ad to also show on the page. For video players that can receive audio ads, Google strongly recommends using companion banners, so the player does not stay blank while the audio plays. A few cautions: the slot must have the same size as the companion, responsive ads are not supported as video companions and, if the player is inside an iframe, you need a GPT proxy script.
Step by step
Implemented example
<!-- No head: GPT com um espaço que aceita complementar -->
<script async
src="https://securepubads.g.doubleclick.net/tag/js/gpt.js"></script>
<script>
window.googletag = window.googletag || { cmd: [] };
googletag.cmd.push(function () {
googletag
.defineSlot('/1234567/exemplo', [728, 90], 'companionDiv')
.addService(googletag.companionAds())
.addService(googletag.pubads());
googletag.companionAds().setRefreshUnfilledSlots(true);
googletag.pubads().enableVideoAds();
googletag.enableServices();
});
</script>
<!-- No body: a caixa do complementar, do mesmo tamanho -->
<div id="companionDiv" style="width:728px; height:90px;">
<script>
googletag.cmd.push(function () { googletag.display('companionDiv'); });
</script>
</div>
<!-- Na tag do IMA, os tamanhos dos complementares vão em ciu_szs:
...&ciu_szs=728x90&... -->What Google recommends
Tips
Watch out
IMA for HTML5 only recognizes GPT spaces on the main page. In an iframe, without the proxy script, the companion does not appear.
The companion must be the same size as the space. A 728x90 space does not receive a 300x250 companion.
A player with IMA must send the companion sizes in the ciu_szs parameter. Without it, the server does not know which sizes the page accepts.
In video or audio that plays on its own, a regular banner may appear for a moment. Google recommends disableInitialLoad to avoid this.
No. It always depends on the master ad playing in the player. If there is no companion, the space can receive another ad from your network.
A VAST ad can carry up to 6 companion display ads.
Yes. In video players that can receive audio ads, Google strongly recommends using companion banners, so the player does not stay blank while the sound plays.
It makes GPT and the IMA SDK use the same correlator, a number that is the same in all ad requests of the same page view.
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.