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

  1. Install Linear ads and Ad controls from the marketplace. The break is drawn by Ad controls, so both must be in the video.
  2. List your breaks in Linear ads' settings, or keep the default: one preroll.
  3. The site connects its ad server (its tag or VMAP) and allows the plugin; until it does, no ads play.
The site has the last word
A site can turn breaks off (an ad-free account), cap how many play and how long, space them out, or allow only some placements. A break it does not allow is refused, and the video plays on.

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.

PropTypeDefaultDescription
tagUrlstring''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.
vmapUrlstring''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>.
templatestring'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.
holdSecondsnumber30How 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.
declaredobject{}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.
targetWidthnumber1280The ad's MP4 closest to this size plays; also the size used for an MP4 that declares none.
targetHeightnumber720See 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

PropTypeDefaultDescription
startpreroll-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.
endpostroll-A quarter second before the end, while the video still plays.
A preroll, two midrolls and a postroll
"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 (prerollStart onPlay); after it the video plays on.

What the ad server may answer

PropTypeDefaultDescription
InLine adVAST 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.
Linearvideo-Its first Linear with a <Duration>; the progressive video/mp4 MediaFile closest to the target size.
skipoffsetseconds or N%-Becomes the break's skip time (at most the ad's length). No skipoffset: not skippable.
VideoClicksURLs-<ClickThrough> becomes Learn more; <ClickTracking> fires on the click.
Advertisertext-Shown in the player's label: Ad · Acme Shoes.
Relative URIsURLs-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 declared rides on every break with the break's adBreakId and adId, 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.

PropTypeDefaultDescription
startVAST event-The ad started playing: its <Impression> URLs and the start trackers.
firstQuartile, midpoint, thirdQuartileVAST events-The ad reached a quarter, half, three quarters of its length.
completeVAST event-The ad played to its end.
skipVAST event-The viewer skipped.
pause, resumeVAST 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, unmuteVAST events-The viewer muted or unmuted the ad.
ClickTrackingclick-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:

PropTypeDefaultDescription
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).
Count the ads a viewer watched
// 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.

PropTypeDefaultDescription
timeoutreason-The ad server did not answer within 2 seconds.
networkreason-The request failed, was not allowed by the site's network rules, or the server answered an HTTP error.
invalidreason-The answer is not VAST XML.
emptyreason-No ad.
wrapperreason-Every ad in the answer is a Wrapper.
noMatchreason-No progressive MP4 to play.
requestreason-The player did not answer the break request within 3 seconds.
playbackreason-The break started but failed: the ad did not load or play, or its video failed while playing.
vmapreason-The VMAP could not be read; no ads play.