Define advertising policies

30/11/2019
The YouTube XML format is being replaced by DDEX (music only) and CSV templates (all industries). YouTube strongly discourages any new implementations of the YouTube XML format. This page should be used solely as reference material for existing implementations. Visit Using the YouTube DDEX feed for more information about the new format.
The features described in this article are available only to partners who use YouTube's Content Manager to manage their copyrighted content.

You use the <ad_policy> tag to specify which types of ads YouTube can show during a video or on a channel page or video watch page. As with ownership and rights policy tags, you can apply the same ad policy to as many videos as you like.

The subtags of <ad_policy> identify the permitted advertising formats:

In-stream ads

In-stream ads play within the video player and are the only content displayed in the player while they are playing. In that sense, they are analogous to television commercials. In-stream ads can play either before a video (pre-roll), during a video at designated times (mid-roll), or at the end of a video (post-roll).

YouTube does not show in-stream ads by default. You must explicitly enable them in the ad policy, using the <instream> tag, and must specify the break times when the ads should run.

You also specify whether a video shows TrueView in-stream ads or standard in-stream ads. (Note that your partner account must be configured to allow you to show each type of in-stream ad.) YouTube allows both types of ads by default. If your partner account is configured to show both standard and TrueView in-stream ads, both of those types will be eligible to run unless you use the <instream> tag's attributes to disable a particular type of in-stream ad from displaying.

Overlay ads

Overlay ads occupy the bottom 20 percent of the video player. (In the standard 640px by 360px player, the overlay is 640px by 72px.) The video that the user is watching continues playing while the overlay displays. Overlay ad settings also govern YouTube's ability to show ads in a 300px by 250px companion ad slot that displays to the right of the video player.
The list below explains the types of overlay ads that YouTube supports. By default, YouTube does show overlay ads for a video. Thus, you would need to use an ad policy to explicitly disallow the use of such ads.

InVideo ads

InVideo Ads have the following components:

  • A transparent overlay can occupy the bottom 20 percent of the video player.
  • A 300px by 250px companion ad can display to the right of the video player

If you enable a video to show InVideo Ads, then the video could show either the overlay, the companion ad, or both. If an overlay and a companion ad both display, then both ads will be from the same campaign.

When a user clicks on either an InVideo overlay or companion ad, one of the following actions will occur:

  • Another YouTube video will open and play inside the player. For some advertising campaigns, the other YouTube video will play automatically as a post-roll ad after the main video has ended.​
  • A new browser window will open the advertiser's website.

AdSense ads

AdSense ads can be overlay ads, 300px by 250px image display ads, or text ads displayed in a 300px by 250px area. In addition, the overlay ads themselves could also be text or image ads.

If you enable AdSense overlay ads for a video, then Youtube handles the 300px by 250px ad slot differently depending on whether the video is playing on a channel page or a video watch page:

  • When the video plays on a channel page, the page could also display an image ad to the right of the channel's video player.
  • When the video plays on its video watch page, the page could also display image or text ads in the space to the right of the video player.

The following examples show different types of ad policies:

  1. Enabling pre-roll and post-roll ads – This example shows how to enable pre-roll and post-roll instream ads.
    <ad_policy video="/external/video[@id='VIDEO_ID_1_']">
        <instream/>

        <video_breaks video="/external/video[@id='VIDEO_ID_1_']">
            <break time="0"/>
            <break time="-1"/>
        
  2. Enabling in-stream ads and disabling AdSense overlay ads – This example shows how to enable in-stream ads while disabling AdSense overlay ads.
    ​<ad_policy video="/external/video[@id='VIDEO_ID_1_']">
          <instream/>
          <overlay>
              <adsense_for_video>Deny
         
        
      <video_breaks video="/external/video[@id='VIDEO_ID_1_']">
          <break time="0"/>
          <break time="00:06:12"/>
          <break time="00:11:25"/>
          <break time="00:20:37"/>
          <break time="-1"/>
     

* Nguồn: Youtube