Appearance
Display
A display (banner) ad is a form of online advertising that consists of an image or rich media content displayed on a webpage.
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 |
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 |
js
// define slots
aps.record("ad/slot/define", {
item: [
{
id: "div-slot-1",
spec: {
placement: {
tagid: "name-for-reporting",
display: {
displayfmt: [{ w: 300, h: 250 }],
},
},
},
},
],
});
// define slots
aps.record("ad/slot/define", {
item: [
{
id: "div-slot-1",
spec: {
placement: {
tagid: "name-for-reporting",
display: {
displayfmt: [{ w: 300, h: 250 }],
},
},
},
},
],
});
js
// define slots
aps.record("ad/slot/define", {
slots: [
{
slotID: "div-slot-1",
slotName: "name-for-reporting",
sizes: [[300, 250]],
},
],
});
// define slots
aps.record("ad/slot/define", {
slots: [
{
slotID: "div-slot-1",
slotName: "name-for-reporting",
sizes: [[300, 250]],
},
],
});
Fetch bids, attach targeting, request ads
Fetch bids for the slots declared in the item
array. Attach bid responses as custom targeting to the corresponding GPT slots. Request ads from Google Ad Manager (GAM).
js
// fetch bids
aps
.record("ad/targeting/fetch", {
itemIds: ["div-slot-1"],
})
.then(() => {
googletag.cmd.push(function () {
// set custom targeting on GPT slots
aps.read("ad/attachTargeting")?.({
itemIds: ["div-slot-1"],
adServer: "googletag",
});
// request ads from GAM
googletag.pubads().refresh();
});
});
// fetch bids
aps
.record("ad/targeting/fetch", {
itemIds: ["div-slot-1"],
})
.then(() => {
googletag.cmd.push(function () {
// set custom targeting on GPT slots
aps.read("ad/attachTargeting")?.({
itemIds: ["div-slot-1"],
adServer: "googletag",
});
// request ads from GAM
googletag.pubads().refresh();
});
});