Ad Slots Plugin
mp4e:ad-slots turns surfaces in your video — a billboard, a poster, a screen — into ad slots that the site playing the video fills from its own VAST ad server.
Overview
Ad slots (mp4e:ad-slots, an official plugin) is a VAST 4 client that runs in the background of the player. You declare the slots in your video; the site that plays it decides whether to sell them by naming its ad server. One request fills every slot: the ad's linear video goes to the video slot, and each companion image to the image slot with the nearest shape.
Without an ad server — or when it does not answer within 2 seconds, or answers with nothing — every slot shows the house creative you chose, and the video plays as you made it. How a site connects its ad server and follows the ads is on Ads in Video.
Adding ad slots to a video
- Embed a house creative for each slot in the video's media library.
- Make each surface a replacement zone (surface tracking keeps it on the building or the screen).
- Install Ad slots from the marketplace and list your slots in its settings.
- Set each zone's source to read the plugin's creatives, with the house creative as the fallback (below).
- On each zone's overlay, run Slot Visible on show and on hide (below).
Slots
The plugin's slots setting lists them. Give each surface the proportions of a standard IAB size, so standard creatives fit it edge to edge:
| Prop | Type | Default | Description |
|---|---|---|---|
id | string | - | The slot's id: lower-case letters, digits, - and _ (for example billboard). The zone's source and the Slot Visible actions name it. |
kind | 'image' | 'video' | - | Image slots take the ad server's companion images; one video slot takes its linear video ad. |
size | string | - | Width x height of the IAB size the surface matches, such as 970x250 (billboard) or 300x600 (half page). It gives the slot its shape and is sent to the ad server. A video slot without one is 1280x720. |
houseCreative | string | - | What the slot shows when it is not filled — a media item embedded in the video. Name the same creative as the zone's fallback. |
viewableSeconds | number | 1 (image), 2 (video) | How long the ad must be on screen in one showing before its impression counts. |
"slots": [
{ "id": "billboard", "kind": "image", "size": "970x250", "houseCreative": "media://house_billboard" },
{ "id": "poster", "kind": "image", "size": "300x600", "houseCreative": "media://house_poster" },
{ "id": "screen", "kind": "video", "size": "1280x720", "houseCreative": "media://house_screen" }
]The plugin's other settings — the ad server tag, a tag per slot, the country variable and the viewer id variable — belong to the site, which sets them through overrides; see Ads in Video.
The slot zones
Each slot is an ordinary replacement zone. Its source and fit read the slot from the plugin's variable, falling back to the house creative; set the screen's zone to content type video:
src: {{mp4e:ad-slots:creatives.billboard.src || 'media://house_billboard'}}
fit: {{mp4e:ad-slots:creatives.billboard.fit || 'fill'}}The zone follows the variable as it changes, so a new ad shows the moment it is filled — in the middle of a shot if need be: the old ad stays until the new one is ready, so it never flashes. A zone that has left the screen forgets its old ad — when it comes back with a new one, it stays transparent until that ad is ready. A creative that fails to load leaves the zone transparent, showing the original footage.
Telling the plugin a slot is on screen
A plugin cannot see which overlays are showing, so each slot's overlay tells it — on show and on hide, including after a seek:
// On Show of the billboard's overlay
{ "type": "pluginAction", "pluginId": "mp4e:ad-slots", "actionId": "slotVisible",
"config": { "slotId": "billboard", "visible": true } }
// On Hide
{ "type": "pluginAction", "pluginId": "mp4e:ad-slots", "actionId": "slotVisible",
"config": { "slotId": "billboard", "visible": false } }| Prop | Type | Default | Description |
|---|---|---|---|
slotVisible | { slotId, visible } | - | The slot's overlay was shown (visible: true) or hidden (visible: false). Answers { accepted: true, slotId, visible }, or { accepted: false, reason } — reason is slotId (no such slot) or visible (not true or false). |
What counts
- Each slot's time on screen is counted from the moment that slot is shown. An image slot counts after 1 second in one showing; a video slot after 2 seconds of playing.
- Then the plugin fires the ad's impression trackers once and the slot's creative-view trackers, and emits impression.
- The video slot then reports start, first quartile, midpoint, third quartile and complete as one uninterrupted showing reaches each part of the ad's length, and fires the matching trackers, each once per creative. The zone's video starts from the beginning each time the slot is shown.
- Nothing counts while the page is in the background. Leaving the screen ends the showing and the next one starts from zero; an impression is counted once per creative.
Events and the variable
Rules and the site receive these as plugin:mp4e:ad-slots:<event>:
| Prop | Type | Default | Description |
|---|---|---|---|
adRequested | { requestId, slots, country, sent, server } | - | A request went to the ad server. |
adFilled | { requestId, slotId, kind, creativeId, src, fit } | - | A slot got a creative. |
adFallback | { requestId, slotId, reason } | - | A slot keeps its house creative. reason: timeout, network, invalid, empty, wrapper or noMatch. |
adError | { requestId, reason, message } | - | A request failed (timeout, network, invalid or wrapper). |
impression | { requestId, slotId, kind, creativeId, seconds, sent } | - | A filled slot counted; its impression trackers fired. |
quartile | { requestId, slotId, creativeId, event, seconds } | - | The video ad reached start, firstQuartile, midpoint, thirdQuartile or complete on screen. |
viewTime | { slotId, creativeId, filled, seconds } | - | A slot left the screen, or changed creative: how long it was shown. filled is false for the house creative. |
Installing the plugin adds one variable, mp4e:ad-slots:creatives, an object keyed by slot id holding the filled slots (a slot that is not filled is absent). The plugin is its only writer.
| Prop | Type | Default | Description |
|---|---|---|---|
src | string | - | The creative's URL (an image, or an MP4 for the video slot). |
fit | 'fill' | 'contain' | - | fill when the creative has the slot's shape; contain when it does not, so it is letterboxed, never stretched. |
kind | 'image' | 'video' | - | The slot's kind. |
creativeId | string | - | The creative's id in the ad server's answer. |
durationSeconds | number | - | The video ad's length (video slot only). |