Open workspace

Implementation guide

Mid-roll video

Mid-roll video ads

A video ad that comes in the middle of the content, like a commercial break, and then the video continues from where it stopped.

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

Understand it in 1 minute

What mid-roll video is

Think of a football game on TV: at halftime the commercials come in and then the game comes back. The mid-roll is the commercial break of your site's video. The video stops at an agreed point, plays one or more ads inside the same player and then continues exactly where it stopped. When several ads come in a row, Google calls this group an ad pod, which is like a block of commercials.

Who decides when the breaks happen? In Ad Manager, this is done by video ad rules. They say when and how ads appear inside a video. You can choose fixed times, such as seconds 60, 120 and 180, or a break every so many seconds. You can also use cue points, which are small markers inside the video showing the best places to stop, such as the end of a scene. The player receives this plan in a VMAP response, which works like a schedule of the breaks, and the IMA SDK plays each break at the right time.

There are important details. Video ad rules only exist in Google Ad Manager 360 with an advanced video contract. For mid-roll to work, Ad Manager needs to know how long the video is and where the stopping points are. You can register your videos in Ad Manager (this is called content ingestion) and send the cmsid and vid codes in the tag. Or, without that registration, you can send the video duration in seconds (vid_d) and the list of stopping points in milliseconds (allcues). Google says the duration must be sent to get mid-rolls.

IMA also needs to know at which second the video is. That is why you hand the video element itself to IMA and start the ads manager before the content begins, because that is when it starts counting time. The mid-roll makes sense in videos where the person stays watching for a good while. Always think about the viewer: Ad Manager lets you limit how many ads go in each break, how long each can last and use frequency caps per break, per video or both.

Step by step

How to implement

  1. Turn on ad rulesIn Ad Manager 360, go to Admin, Video and audio, Audio and video settings. Turn on the Ad rules option and save.
  2. Create a standard ruleGo to Video, Ad rules, New ad rule. Give it a name, choose Standard as the type, choose the priority and set Video midroll ads to Enable.
  3. Choose when the breaks happenUnder mid-roll frequency, choose At fixed times, Every n seconds, At fixed cue points or Every n cue points. Then set the pod: Maximum number of ads and Maximum ad duration. The times must be whole numbers.
  4. Send the duration and points in the tagIn the tag, request ad rules with ad_rule=1. Without videos registered in Ad Manager, provide the duration in seconds (vid_d) and the stopping points in milliseconds (allcues). With registered videos, send cmsid and vid.
  5. Connect IMA to the videoGive IMA the video element, which reports the current time of the video. Initialize the ads manager before playing the content, because that is when IMA starts tracking time.
  6. Pause and resume at the breaksPause the video when IMA asks for a pause and play again when it asks to continue. This way each break starts and ends at the right moment.

Implemented example

The code and how it looks on screen

It goes in the same player code with IMA: only the tag changes (with ad_rule=1, vid_d and allcues) and the video element is given to IMA so it knows the time.
<script src="//imasdk.googleapis.com/js/sdkloader/ima3.js"></script>
<script>
  // Vídeo de 10 minutos (vid_d=600)
  // com intervalos em 2 e 5 minutos (allcues em ms)
  var adsRequest = new google.ima.AdsRequest();
  adsRequest.adTagUrl = 'https://pubads.g.doubleclick.net/gampad/ads?' +
      'iu=/1234567/exemplo&sz=640x480&env=vp&gdfp_req=1' +
      '&ad_rule=1&output=vmap&vid_d=600&allcues=120000,300000' +
      '&unviewed_position_start=1&vpa=click&vpmute=0&plcmt=1' +
      '&description_url=https%3A%2F%2Fwww.exemplo.com%2Fvideo&correlator=';
  adsRequest.linearAdSlotWidth = 640;
  adsRequest.linearAdSlotHeight = 400;
  adsLoader.requestAds(adsRequest);

  adsLoader.addEventListener(
      google.ima.AdsManagerLoadedEvent.Type.ADS_MANAGER_LOADED,
      function (e) {
        // O próprio <video> informa o tempo atual (currentTime) ao IMA
        adsManager = e.getAdsManager(video);
        adsManager.addEventListener(
            google.ima.AdEvent.Type.CONTENT_PAUSE_REQUESTED,
            function () { video.pause(); });
        adsManager.addEventListener(
            google.ima.AdEvent.Type.CONTENT_RESUME_REQUESTED,
            function () { video.play(); });
      });

  // No clique de play: init() antes de tocar o conteúdo
  // adDisplayContainer.initialize();
  // adsManager.init(640, 360, google.ima.ViewMode.NORMAL);
  // adsManager.start();
</script>
On desktopThe video pauses at the marked point, the ad plays in the same player and, when it ends, the content continues where it stopped.
On mobileIt works the same way inside the mobile player. If the person drags the video bar forward and the player does not handle it, several breaks can play one after another.

What Google recommends

Do and don't

Allowed

  • Choose the breaks by fixed times, every N seconds, at fixed cue points or every N cue points.
  • Serve mid-roll without registering the videos in Ad Manager, by sending vid_d and allcues in the tag.
  • Define how many ads play in each break and how long each can last.
  • Use a frequency cap per break, per video or both.
  • Turn off the automatic start of breaks in IMA and decide on the spot whether each ready break will play.

Not allowed

  • You cannot have mid-roll without providing the content duration: Google says vid_d must be sent for mid-rolls.
  • Session rules do not work for mid-roll: they can only be applied to pre-roll.
  • Do not leave the video and ad controls covered, hidden or not working.
  • Do not signal the end of content when what finished was an ad: that signal is only for the end of the video.

Tips

To do it right

Watch out

Common errors

Signaling content end at the end of the ad

The content-end signal is only for when the video ends. Since IMA may use the same player for ads, signaling at the end of an ad confuses the SDK.

Playing the video before connecting IMA

IMA only starts tracking time when the ads manager is initialized. That is why Google asks you to initialize it always before playing the content.

Player that changes the time while dragging

If your player updates the time during bar dragging, Google recommends giving IMA your own object that reports the correct time.

Look for ad rules in an account without 360

Video ad rules are only for Google Ad Manager 360 with an advanced video contract. In a regular account, this option does not appear.

Frequently asked questions

Do I need to register my videos in Ad Manager?

No. Google says content ingestion is not required for mid-rolls with ad rules. Without it, send the duration (vid_d) and the stopping points (allcues) in the tag.

What is a cue point?

It is a small marker at a point in the video saying a break can go there. In the tag, cue points are in milliseconds, separated by commas, like 10000,20000.

Can I have mid-roll without ad rules?

Google says ad rules are required for Ad Manager to return mid-rolls, and they are an Ad Manager 360 feature. The video duration (vid_d) must also be sent.

How many ads play in each break?

You decide in the pod with Maximum number of ads. The option No maximum only exists in Optimized pods, which also let you limit the total duration of the break.

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