Open workspace

Implementation guide

Post-roll video

Post-roll video ads

A video ad that plays in the same player right after the video ends, like the commercials at the end of a TV show.

  • Ad Manager
  • Ad Exchange
  • AdSense (via Ad Manager)
  • inside the video player (mobile and desktop)
Desktop
Mobile

Understand it in 1 minute

What the post-roll video is

You know when a TV show ends and, before the next one starts, a few commercials play? Post-roll is that on your site: a video ad that plays at the end of the video, inside the same player. The person has already watched what they wanted and the ad appears right after. Pre means before, mid means middle and post means after.

The secret of post-roll is telling the player that the video has ended. The IMA SDK, which is Google's code package for putting ads in the player, cannot guess on its own that the content has finished. Google's guide says it like this: for the post-roll to play, you need to tell the SDK when the content has ended, and then it plays the end break, if one is scheduled. This notice should only be sent when the video ends, never when an ad ends, because IMA may use the same player for the ads. It is like ringing the school bell only when the class ends, and not in the middle of recess.

Breaks can be organized by video ad rules, a Google Ad Manager 360 feature. In them, the post-roll can be turned on (Enable), turned off (Disable) or left for a lower-priority rule to decide (Defer). With rules, the answer comes in VMAP, which is like a TV schedule, saying which breaks exist. Without rules, the player itself can make the request at the end of the video and say in the tag that it is a post-roll.

When is it worth it? When you already have videos on the site and want one more moment for an ad that does not interrupt the start or middle of the content. The rules for any in-stream ad still apply: the space must be declared the right way, the controls cannot be hidden and only one visible autoplay player can play at a time. And, when all the breaks have played, IMA announces it with its own event, which you can use to tidy up the page.

Step by step

How to implement

  1. Set up the player with IMABuild the player with the IMA SDK as for pre-roll: the IMA script, the ad container over the video, AdsLoader and AdsRequest with your tag.
  2. Turn on post-roll in the ruleIn Ad Manager 360, go to Video, Ad rules, New ad rule, choose Standard and set video post-rolls to Enable. Then set Maximum number of ads and Maximum ad duration.
  3. Adjust the tagWith ad rules, the tag carries ad_rule=1. Without rules, the player makes the request at the end of the video and can send vpos=postroll, which says the request is for the end of the video.
  4. Signal the end of the contentListen for the end of the video and call the AdsLoader's content complete notice. Remove that listener when an ad starts and put it back when the content returns.
  5. Finish after the adsIMA announces with the ALL_ADS_COMPLETED event when all the breaks have played. Use this notice to clean up the player, if needed.

Implemented example

The code and how it looks on screen

It goes along with the player code with IMA: it signals the end of the video so the post-roll plays and handles the listeners while the ads run.
<script>
  var video = document.getElementById('conteudo');

  // Avisa o IMA que o CONTEÚDO acabou (nunca no fim de um anúncio)
  var contentEndedListener = function () { adsLoader.contentComplete(); };
  video.addEventListener('ended', contentEndedListener);

  adsLoader.addEventListener(
      google.ima.AdsManagerLoadedEvent.Type.ADS_MANAGER_LOADED,
      function (e) {
        adsManager = e.getAdsManager(video);

        adsManager.addEventListener(
            google.ima.AdEvent.Type.CONTENT_PAUSE_REQUESTED,
            function () {
              // anúncio vai tocar: tira o ouvinte de fim do vídeo
              video.removeEventListener('ended', contentEndedListener);
              video.pause();
            });

        adsManager.addEventListener(
            google.ima.AdEvent.Type.CONTENT_RESUME_REQUESTED,
            function () {
              // conteúdo volta: coloca o ouvinte de novo
              video.addEventListener('ended', contentEndedListener);
              if (!video.ended) { video.play(); }
            });

        adsManager.addEventListener(
            google.ima.AdEvent.Type.ALL_ADS_COMPLETED,
            function () { console.log('Todos os intervalos tocaram'); });
      });
</script>
On desktopWhen the video reaches the end, the ad plays in the same player. After the ad, the video does not restart by itself.
On mobileSame as on a computer: the ad plays in the phone's player right after the video ends.

What Google recommends

Do and don't

Allowed

  • Play an ad at the end of the video, inside the same player, using the IMA SDK.
  • Turn on, turn off or leave the post-roll for another rule to decide in the Ad Manager 360 video ad rules.
  • Make the request at the end of the video without ad rules and say in the tag that it is a post-roll.
  • Use the all ads completed event to tidy up the page after the last break.

Not allowed

  • Do not signal content end when what finished was an ad: the notice is only for the end of the video.
  • Do not leave the video and ad controls covered, hidden or not working.
  • You cannot declare the wrong space: a player with video must be In-stream or Companion content.
  • Do not have more than one visible autoplay player playing at the same time.
  • Do not use IMA products to earn money from YouTube videos.

Tips

To do it right

Watch out

Common errors

Not signaling the end of the video

Google says that, for the post-roll to play, the SDK needs to know the content has ended. Without this notice, the end break does not happen.

Signaling at the end of an ad

If the end-of-video listener stays on while the ad plays in the same player, the notice can go out at the wrong time. Remove the listener on pause and put it back when the content returns.

Telling a finished video to play

After the post-roll, IMA asks to resume the content. If the video has already ended, do not tell it to play again, or it may restart without the person asking.

Frequently asked questions

Why does my post-roll not appear?

One possible reason is not telling IMA that the video ended. Google asks that the site signal the end of the content so the SDK plays the end break, if one is scheduled.

Do I need ad rules to have a post-roll?

Not necessarily. With rules (Ad Manager 360), the post-roll comes scheduled in the VMAP. Without rules, the player can request the ad at the end of the video and send vpos=postroll in the tag.

Does the post-roll interrupt the video?

No. It plays after the content ends, in the same player.

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