Linear Ads Plugin
mp4e:linear-ads plays the site's VAST and VMAP video ads before, during and after your video, as breaks the player runs and returns from.
Overview
Linear ads (mp4e:linear-ads, an official plugin) runs in the background of the player. When a break is due — a preroll, a midroll, a postroll — it asks the site's VAST 4 ad server for an ad and hands it to the player as a break. The player pauses the video at its position, plays the ad in the same video element with the Ad controls on top, and resumes the video where it was.
The player decides whether a break may run, when it starts and ends, and when it may be skipped: the ad's skip offset is a request, never a promise. The site that plays the video names the ad server and allows the plugin to request breaks; how is on Ads in Video. Without an ad server the plugin does nothing and the video plays as made.
Adding linear ads to a video
- Install Linear ads and Ad controls from the marketplace. The break is drawn by Ad controls, so both must be in the video.
- List your breaks in Linear ads' settings, or keep the default: one preroll.
- The site connects its ad server (its tag or VMAP) and allows the plugin; until it does, no ads play.
Settings
The ad server settings belong to the site, which sets them through overrides (plugins['mp4e:linear-ads'].defaultConfig); the breaks can be set by either.
| Prop | Type | Default | Description |
|---|---|---|---|
tagUrl | string | '' | The VAST tag every break requests. {cachebuster} is filled with a new random number. Set by the site, through overrides. Empty, and no vmapUrl: the plugin does nothing. |
vmapUrl | string | '' | A VMAP whose ad breaks — each with its own VAST tag — are used instead of breaks. Set by the site. |
breaks | { offset: string; breakId?: string }[] | [{ offset: 'start' }] | When the ads play (below). breakId names the break in events; without one it is break_<n>. |
template | string | 'mp4e:ad-controls' | The plugin that draws the break: pause, mute, the time remaining, skip and Learn more. It receives showPause and showMute in its config, and clickThroughUrl when the ad has one, and must be installed in the video too. |
holdSeconds | number | 30 | How long a shoppable ad waits on its last frame, with its card open, before the video resumes by itself — unless the viewer has interacted with the ad, when only their Continue (or the site ending the break) resumes it. The site's maxHoldSeconds is its limit: a longer wait is refused — a maxHoldSeconds below holdSeconds refuses every shoppable ad. |
declared | object | {} | Set by the site: its own attribution (e.g. { affiliate, campaign }) sent with every break and returned on every outcome. An ad cannot change it. |
targetWidth | number | 1280 | The ad's MP4 closest to this size plays; also the size used for an MP4 that declares none. |
targetHeight | number | 720 | See targetWidth. |
prerollStart | 'onPlay' | 'onLoad' | 'onPlay' | When the preroll is requested. onPlay: once the video plays — a page that does not autoplay shows no ad until the viewer presses play, and a viewer who starts past the first second gets no preroll. onLoad: as soon as the plugin starts, even while the video is paused. |
adControls | { showPause?: boolean; showMute?: boolean } | { showPause: true, showMute: true } | Whether the viewer can pause and mute the ad. Passed to the template as showPause / showMute; false hides that button. |
Breaks and offsets
| Prop | Type | Default | Description |
|---|---|---|---|
start | preroll | - | Before the video, when the video starts at its beginning. |
HH:MM:SS(.mmm) | midroll | - | When playback reaches this time, for example 00:05:00. 00:00:00 is a preroll. |
N% | midroll | - | At this share of the video, once its length is known. 0% is a preroll, 100% a postroll. |
end | postroll | - | A quarter second before the end, while the video still plays. |
"breaks": [
{ "offset": "start", "breakId": "preroll" },
{ "offset": "00:05:00", "breakId": "mid-1" },
{ "offset": "50%", "breakId": "mid-2" },
{ "offset": "end", "breakId": "postroll" }
]- A break is due when playback moves forward across its offset; going back plays nothing.
- A seek past several breaks plays the last one passed; afterwards the viewer is where the seek landed.
- Each break is tried once: refused, failed or without an ad, it is not asked for again.
- When the plugin restarts in the middle of the video (for example when the site changes its overrides), the preroll and the breaks already passed do not play.
- With a VMAP, its ad breaks replace this list, each with its own tag.
- A break lasts at most the ad's length plus 10 seconds of playing time: an ad that stalls ends there and the video resumes. Time the viewer keeps the ad paused does not count.
- The preroll waits until the video plays (
prerollStartonPlay); after it the video plays on.
What the ad server may answer
| Prop | Type | Default | Description |
|---|---|---|---|
InLine ad | VAST 2.0–4.x | - | The break plays the first <Ad> with an <InLine>; from an ad pod, that is its first ad. An answer whose ads are all Wrappers is reported as adError reason wrapper. |
Linear | video | - | Its first Linear with a <Duration>; the progressive video/mp4 MediaFile closest to the target size. |
skipoffset | seconds or N% | - | Becomes the break's skip time (at most the ad's length). No skipoffset: not skippable. |
VideoClicks | URLs | - | <ClickThrough> becomes Learn more; <ClickTracking> fires on the click. |
Advertiser | text | - | Shown in the player's label: Ad · Acme Shoes. |
Relative URIs | URLs | - | Resolved against the tag URL. |
Shoppable ads
An ad whose Linear carries MP4E <AdParameters> naming the shoppable template plays with the Ad offer card over the Ad controls: the viewer can order, take an email offer or ask to be reminded, and the ad holds on its last frame until the viewer continues (holdSeconds). The ad's offer is data for Ad offer; an ad never brings code. Install Ad offer in the video too.
- Attribution: the site's
declaredrides on every break with the break'sadBreakIdandadId, and comes back on every outcome (see Outcomes from an ad). - Remind me: the first time a viewer asks, the same ad comes back once as a postroll that opens straight on its card. Its trackers do not fire again. A postroll ad does not offer Remind me.
Tracking
The plugin fires the ad's trackers as the player reports the break — the player measures the progress, not the plugin. The macros [CACHEBUSTING] and [TIMESTAMP] are filled. No viewer id is sent: {viewerId} in a tag and [IFA] in a tracker are always empty.
| Prop | Type | Default | Description |
|---|---|---|---|
start | VAST event | - | The ad started playing: its <Impression> URLs and the start trackers. |
firstQuartile, midpoint, thirdQuartile | VAST events | - | The ad reached a quarter, half, three quarters of its length. |
complete | VAST event | - | The ad played to its end. |
skip | VAST event | - | The viewer skipped. |
pause, resume | VAST events | - | The viewer paused the ad, then played it again. A pause is reported about a tenth of a second after it happens (the ad pausing as it ends is not a pause). |
mute, unmute | VAST events | - | The viewer muted or unmuted the ad. |
ClickTracking | click | - | The viewer pressed Learn more. |
Events
Rules and the site receive these as plugin:mp4e:linear-ads:<event>. breakId is the break's id from your settings or the VMAP:
| Prop | Type | Default | Description |
|---|---|---|---|
adRequested | { breakId, server } | - | A break is due: a request went to its VAST tag. server is the ad server's origin. |
adStarted | { breakId, adId } | - | The player started the break. |
adProgress | { breakId, event } | - | The ad reached start, firstQuartile, midpoint, thirdQuartile or complete, or the viewer paused, resumed, muted or unmuted it (pause, resume, mute, unmute); its trackers fired. |
adSkipped | { breakId, atSeconds } | - | The viewer skipped the ad; its skip trackers fired. |
adCompleted | { breakId } | - | The break played to its end. |
adEnded | { breakId, reason, label? } | - | One of the plugin's breaks ended, however it ended: completed, skipped, returned, maxSeconds, cancelled or error. returned means the ad's card sent the viewer back to the video after they engaged; label is the card's reason (remindLater, orderPlaced or formSubmitted). The video resumes. |
adOutcome | { breakId, type, data } | - | The viewer answered one of the plugin's ads: orderPlaced, formSubmitted, remindLater, productSaved or clicked, with fixed fields only. |
adReminder | { breakId } | - | The reminder a viewer asked for (Remind me) started at the end of the video. |
adRefused | { breakId, reason } | - | The player refused the break (for example the site did not allow the plugin, or the plugins the ad would run are not allowed: plugin). It is not asked for again. |
adError | { breakId, reason } | - | The break could not be played. reason: timeout, network, invalid, empty, wrapper, noMatch, request, playback, or vmap (breakId null). |
// A rule on plugin:mp4e:linear-ads:adCompleted
{ "type": "setVariable", "variableId": "adsWatched", "operation": "increment", "value": 1 }When there is no ad
Whatever fails, the video plays on: a break that cannot be filled is skipped and reported with adError; one the player refuses, with adRefused and the player's reason.
| Prop | Type | Default | Description |
|---|---|---|---|
timeout | reason | - | The ad server did not answer within 2 seconds. |
network | reason | - | The request failed, was not allowed by the site's network rules, or the server answered an HTTP error. |
invalid | reason | - | The answer is not VAST XML. |
empty | reason | - | No ad. |
wrapper | reason | - | Every ad in the answer is a Wrapper. |
noMatch | reason | - | No progressive MP4 to play. |
request | reason | - | The player did not answer the break request within 3 seconds. |
playback | reason | - | The break started but failed: the ad did not load or play, or its video failed while playing. |
vmap | reason | - | The VMAP could not be read; no ads play. |