Appearance
Instream Video
Instream video refers to a type of video ad format that is played within a video player before, during, or after the streaming of online video content. Video ads can appear as pre-roll ads (played before the main video), mid-roll ads (played during the video), or post-roll ads (played after the main video).
Before continuing, make sure you have completed the Getting Started steps.
Define slots
APS provides support for two variations of slot definition: the preferred approach is the OpenRTB and AdCOM slot definition, while the APS slot definition is also available as an option.
OpenRTB slot definition preferred
Parameter | Required | Type | Description |
---|---|---|---|
item | required | [object] | OpenRTB 3.0 |
placement | required | object | AdCOM 1.0 |
item.id | required | string | must match the element ID (div) associated with the corresponding GPT ad slot |
item.placement.tagid | optional | string | how the slot will be presented in APS reporting |
item.placement.video.ptype | optional | integer | specifies video subtype |
APS slot definition legacy
Parameter | Required | Type | Description |
---|---|---|---|
slots | required | [object] | a collection of slot definitions |
slotId | required | string | must match the element ID (div) associated with the corresponding GPT ad slot |
slotName | optional | string | how the slot will be presented in APS reporting |
mediaType | required | string | must be set to video |
js
// define slots
aps.record("ad/slot/define", {
item: [
{
id: "APS_VIDEO_SLOT",
spec: {
placement: {
tagid: "name-for-reporting",
video: {
ptype: 1, // 1, 2, 3, or 4
w: 400,
h: 225,
},
},
},
},
],
});
// define slots
aps.record("ad/slot/define", {
item: [
{
id: "APS_VIDEO_SLOT",
spec: {
placement: {
tagid: "name-for-reporting",
video: {
ptype: 1, // 1, 2, 3, or 4
w: 400,
h: 225,
},
},
},
},
],
});
js
// define slots
aps.record("ad/slot/define", {
slots: [
{
slotID: "APS_VIDEO_SLOT",
slotName: "name-for-reporting",
mediaType: "video",
},
],
});
// define slots
aps.record("ad/slot/define", {
slots: [
{
slotID: "APS_VIDEO_SLOT",
slotName: "name-for-reporting",
mediaType: "video",
},
],
});
Fetch bids, attach targeting, request ads
Fetch bids for the slots declared in the item
array. Append bid response key/values to your video ad server VAST tag. Request ads via video player.
js
// fetch bids
aps
.record("ad/targeting/fetch", {
itemIds: ["APS_VIDEO_SLOT"],
})
.then(() => {
// get slot targeting
const slotTargeting = aps.read("ad/targeting").get("APS_VIDEO_SLOT");
// construct targeting string
let apsParams = "";
for (const el of slotTargeting) {
apsParams += `&${el[0]}=${el[1]}`;
}
// append targeting string as cust_params to VAST tag
vastTag += "&cust_params=" + encodeURIComponent(apsParams);
// request ads via video player...
});
// fetch bids
aps
.record("ad/targeting/fetch", {
itemIds: ["APS_VIDEO_SLOT"],
})
.then(() => {
// get slot targeting
const slotTargeting = aps.read("ad/targeting").get("APS_VIDEO_SLOT");
// construct targeting string
let apsParams = "";
for (const el of slotTargeting) {
apsParams += `&${el[0]}=${el[1]}`;
}
// append targeting string as cust_params to VAST tag
vastTag += "&cust_params=" + encodeURIComponent(apsParams);
// request ads via video player...
});