Ads in the video player

General provisions

VAST is a standard that describes the process of serving banners by a video player and sending statistics to an ad server.

The international media standards are used for embedding ads, including the VAST 2.0, VAST 3.0, and VPAID 2.0 standards. This article describes the final solutions within the framework of these standards.

Ads are served in the following way: the player requests the video banner, displays the contents of the VAST response, and sends statistics on impressions and other events to Adfox (statistics can also be sent to third-party systems using pixels). This can happen either directly between the video player and Adfox, or among the video player, Adfox, and a third-party ad server. When accessing Adfox, the player receives VAST XML as shown in the example.

Direct interaction of the player and Adfox scheme

  1. Ad request: The video player sends a request to Adfox to get VAST.
  2. VAST response: Adfox sends VAST, which contains links to media files and events necessary for serving the banner and collecting statistics.
  3. Send statistics: As events occur during ad serving (for example, the video is loaded, the first quarter, and other events), the player sends statistics on them to Adfox.
Interaction scheme that includes a third-party ad server (Wrapper)

  1. Ad request: The video player sends a request to Adfox to get VAST.

  2. VAST redirect (Wrapper): Adfox sends a VAST response, which contains event links and the URI of a third-party ad server in the <VASTAdTagURI></VASTAdTagURI> tags.

    Sample Wrapper response from Adfox:

    <?xml version="1.0" encoding="UTF-8"?>
    <VAST version="2.0">
    <Ad id="%campaignId%-%user1%">
    <Wrapper>
            <AdSystem>Adfox</AdSystem>
            <VASTAdTagURI>
            <![CDATA[URI of a third-party ad server]]>
            </VASTAdTagURI>
            <Error>
            <![CDATA[%event20%]]>
            </Error>
            <Impression>
            <![CDATA[%event3%]]>
            </Impression>
            <Creatives>
            <Creative>
                    <Linear>
                            <TrackingEvents>
                            ...
                            </TrackingEvents>
                            <VideoClicks>
                            <ClickTracking>
                                    <!![CDATA[%request.reference_mrc%]]>
                            </ClickTracking>
                            </VideoClicks>
                    </Linear>
                    </Creative>
            </Creatives>
            <Extensions>
            ...
            </Extensions>
    </Wrapper>
    </Ad>
    </VAST>    
    
  3. Ad request: After processing the VAST response from Adfox, the video player makes a request to a third-party ad server using the URI that Adfox sent in the <VASTAdTagURI></VASTAdTagURI> tags.

  4. Send statistics: As events occur during ad serving (for example, the video is loaded, the first quarter, and other events), the player sends statistics on them to Adfox and to a third-party ad server by sending requests using VAST links.

The Wrapper response contains the Wrapper tag with a link to a third-party ad server. A third-party server can send a Linear Ad or Wrapper banner that links to another ad server. As a result, the last server in the chain must send all the files necessary for ad serving.

Available preset templates

Note

The templates listed in this section are available for banners with the XML load type.

Linear Ads Video

A full-frame ad that pauses the playback of video content. This is usually a video ad, but static images displayed at a certain time may also be used. This type of ad can be served before the video content is played (pre-roll), in a break during content playback (mid-roll), or after the video playback (post-roll).

The content type is a video file.

Linear-Ad (Pre / Mid / Post-roll) VAST 3.0 Viewability
A template with a viewability check. If more than 50% of the player is within the viewable area, a viewability event is triggered after 2 seconds. Event statistics are available in reports.
Linear-Ad (Pre / Mid / Post-roll) VAST 2.0 Compatible No Click
A template for a video without click support.
Linear-Ad (Pre / Mid / Post-roll) VAST 3.0
A template with click support.

Linear Ads Audio

The content type is an audio file.

Linear-Ad (Pre / Mid / Post-roll) VAST 3.0
A template for an audio without click support.

Nonlinear Ads

An overlay ad that's served simultaneously with the main video playback. This is usually a static image that's placed in the player and occupies part of the player area.

Alert

The Overlay (VAST 3.0) Image, Overlay (VAST 3.0) HTML, and Overlay (VAST 3.0) HTML Custom templates only work with third-party players and aren't supported by the Yandex Video Ads SDK library.

Non-Linear Adfox Overlay Image VAST 3.0

A template for displaying an image on top of a video. The content type is an image.

Parameters for adding a banner to Adfox:

  • Image: A file or link to an image.
  • Width: The image width.
  • Height: The image height.
  • Bottom margin: The player's bottom margin (in percentages).
  • Click URL: The click link.
  • box-shadow: The CSS property that describes the style of the shadow cast by the image on the video.

The required parameters are the image, width, and height.

Sample VAST

Non-Linear Adfox Overlay HTML VAST 3.0

A template for displaying arbitrary HTML on top of a video. The content type is HTML code. The entire banner area is clickable.

Parameters for adding a banner to Adfox:

  • HTML code: The HTML code of the creative.
  • Width: The iframe banner width.
  • Height: The iframe banner height.
  • Bottom margin: The player's bottom margin (in percentages).
  • Click URL: The click link.
  • box-shadow: The CSS property that describes the style of the shadow cast by the image on the video.

The required parameters are the HTML code, width, and height.

Sample VAST

Non-Linear Adfox Overlay HTML Custom VAST 3.0

A template for displaying arbitrary HTML on top of a video. The content type is HTML code. A template where you can set clickable areas.

Parameters for adding a banner to Adfox:

  • HTML code: The HTML code of the creative.
  • Width: The iframe banner width.
  • Height: The iframe banner height.
  • Bottom margin: The player's bottom margin (in percentages).
  • Click URL: The click link.
  • box-shadow: The CSS property that describes the style of the shadow cast by the image on the video.

The required parameters are the HTML code, width, and height.

Sample VAST

Wrapper (VAST redirect)

A VAST instance that redirects to another URL for receiving ads and contains additional pixels. Used for forwarding third-party ads and measuring events in Adfox.

VAST 2.0 Wrapper can link to the contents of VAST 3.0, and VAST 3.0 Wrapper can link to VAST 2.0.

The content type is a link to VAST XML.

Preset InPage templates available in Adfox

Linear-Ad (Pre / Mid / Post-roll) VAST 2.0 for InPage
Template for the video file" content type.
Linear-Ad (Pre / Mid / Post-roll) VAST 3.0 for InPage Viewability
Template for the video file" content type with a viewability check.
Wrapper VAST 2.0 for InPage
Template for Wrapper VAST XML" content.

To learn more about using templates, see InPage video.

You can get a link to VAST in the same way as the usual Adfox ad tags.

Instead of the code, there's a link of the following type:

https://yandex.ru/ads/adfox/168627/getCode?p1=bigha&p2=eojh&puid1=&puid2=&puid3=

You can check the links at a special page.

Use your own player

  1. Connect the ADSDK library in the <head> tag.

    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <script
             type="text/javascript"
             charset="utf-8"
             src="https://yandex.ru/ads/system/adsdk.js">
        </script>
    </head>
    </html>
    
  2. Declare a variable: an object with Adfox parameters.

    var adFoxParameters = {
        adFoxParameters: {
            ownerId: 168627,
            // Parent container tag's ID <video></video>
            containerId: 'videoParent',
            // Adfox Parameters
            params: {
                p1: 'bdcfe',
                p2: 'ekza',
                pfc: 'bupfm',
                pfb: 'frtqn'
            },
        }
     }
    
  3. To start playback, call the play method by passing the Adfox configuration to it.

    ya.videoAd.play({
        // Video element
        videoSlot: document.querySelector('#video'),
        // An element for controls display. The element should not be positioned statically.
        // Parent video element can be used.
        slot: document.querySelector('#videoParent'),
        // Loader config and ads playback config.
        config: adFoxParameters,
    });
    

Implementation example.

Integration instructions:

Ad label

It's mandatory to use the ad label and indicate the advertiser and (or) their website if you launch ads for display in Russia. To learn more about the label and banner menu, see Using the ad label and indicating the advertiser in Adfox banners.

To add an ad label to the player where the Yandex Video Ads SDK library is added, go to the banner parameters in the Ad label list, select “Ad” or “Social ad”. The ad label will be displayed automatically.

To add a token to a non-clickable banner, enable the Show banner menu option in the banner settings. When the banner is served, the menu icon  will be displayed in the upper right corner of it. When a user clicks this icon, the advertiser information and the copy token button appear (if ad register is enabled for the banner and a third-party token is specified).

The banner menu contains a link to the rules for using recommendation technologies. That is necessary to comply with paragraph 3, section 1, article 10.2-2 of Federal Law No. 149-FZ On information, information technologies, and information protection", dated July 27, 2006.

If you don't use the Yandex Video Ads SDK library to show ads, add support of the extension tag to the player in the following format:

<Extensions>
        <Extension type="AdTitle">
                <![CDATA[
                        {
                                "show": "%banner.ad_label%",
                                "domain": "%banner.domain:jsenc%"
                        }
                ]]>
        </Extension>
        <Extension type="AdTune">
                <![CDATA[
                        {
                                "show": "%banner.ad_tune%", 
                                "token": "%banner.token:jsenc%", 
                                "advertiserInfo": "%campaign.advertiser:jsenc%",
                                "socialAdvertising": "%banner.ad_label_social%"
                        }
                ]]>
        </Extension>
</Extensions>

Depending on the ad label settings in the banner, macros take the following values:

Macro Value
%banner.ad_label% 1 (the label is displayed) or 0 (the label is not displayed).
%banner.domain:jsenc% Domain (displayed if %banner.ad_label% is 1 and the Domain field in the banner parameters is entered) or an empty value.
%banner.ad_label_social% The “Social ad” label, 1 (displayed if %banner.ad_label% is 1) or 0 (not displayed).
%banner.ad_tune% 1 (menu is displayed) or 0 (menu is not displayed).
%banner.token:jsenc% Banner token.
%campaign.advertiser:jsenc% Information about the advertiser.

Examples of the extension tag:

The label (without the domain) and the banner menu are displayed
<Extensions>
        <Extension type="AdTitle">
                <![CDATA[
                        {
                                "show": 1,
                                "domain": "",
                                "socialAdvertising": 0
                        }
                ]]>
        </Extension>
        <Extension type="AdTune">
                <![CDATA[
                        {
                                "show": 1, 
                                "token": "token", 
                                "advertiserInfo": "Advertiser information"
                        }
                ]]>
        </Extension>
</Extensions>
The label (with the domain) and the banner menu are displayed
<Extensions>
        <Extension type="AdTitle">
                <![CDATA[
                        {
                                "show": 1,
                                "domain": "example.com",
                                "socialAdvertising": 0
                        }
                ]]>
        </Extension>
        <Extension type="AdTune">
                <![CDATA[
                        {
                                "show": 1, 
                                "token": "token", 
                                "advertiserInfo": "Advertiser information"
                        }
                ]]>
        </Extension>
</Extensions>
The label, domain, and banner menu are not displayed
<Extensions>
        <Extension type="AdTitle">
                <![CDATA[
                        {
                                "show": 0,
                                "domain": "example.com",
                                "socialAdvertising": 1
                        }
                ]]>
        </Extension>
        <Extension type="AdTune">
                <![CDATA[
                        {
                                "show": 0, 
                                "token": "token", 
                                "advertiserInfo": "Advertiser information"
                        }
                ]]>
        </Extension>
</Extensions>
The “Social ad” label is displayed, without a domain and ad menu
<Extensions>
        <Extension type="AdTitle">
                <![CDATA[
                        {
                                "show": 1,
                                "domain": "",
                                "socialAdvertising": 1
                        }
                ]]>
        </Extension>
        <Extension type="AdTune">
                <![CDATA[
                        {
                                "show": 0, 
                                "token": "token", 
                                "advertiserInfo": "Advertiser information"
                        }
                ]]>
        </Extension>
</Extensions>          

Events

The preset Adfox templates have a <TrackingEvents> container with the <Tracking> tags in it. Every <Tracking> element contains the Adfox URI that the video player must use to make a request when a certain event occurs. The event name is passed in the event attribute.

Name Event
The video is selected creativeView
The start of viewing start
The first quarter of viewing firstQuartile
The middle of viewing midpoint
The third quarter of viewing thirdQuartile
The end of viewing complete
Click on the close "x" close
Turn the sound off Mute (the slider for ad volume control is set to 40% by default)
Turn the sound on Unmute (the slider for ad volume control is set to 40% by default)

Response if there's no ad

When there's no suitable ad to serve, Adfox returns the following XML:

  • InStream banner type:

    <?xml version=”1.0”?><nobanner></nobanner>
    
  • InPage banner type:

    <?xml version=”1.0”?><VAST version="2.0"/>
    

To add a default banner for VAST player ads, you need an ad request link. Put this link in square brackets in the VASTAdTagURI block:

<?xml version="1.0" encoding="UTF-8"?>
<VAST version="2.0">
    <Ad id="%placeId%">
        <Wrapper>
            <AdSystem>Adfox.ru</AdSystem>
            <VASTAdTagURI>
                <![CDATA[//yandex.ru/ads/adfox/XXXXXX/getCode?p1=xxx&p2=xxx&pfc=a&pfb=a&plp=a&pli=a&pop=a&puid1=%userValue1%]]>
            </VASTAdTagURI>
            <Impression></Impression>
            <Creatives></Creatives>
        </Wrapper>
    </Ad>
</VAST>

If you need to pass additional parameters to the request code forwarded, use macros:

  • For values of user characteristics: puidN with the %request.puidN% value, where N is the characteristic number. For example, &puid1=%request.puid1%.
  • To send a referer: dl with the %request.referrer:urlenc% value. For example, &dl=%request.referrer:urlenc%.

Copy the code and install it in the XML code of the placement's backup ad and/or banner type.

Contact support

Send an email