Skip to content

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

ParameterRequiredTypeDescription
itemrequired[object]OpenRTB 3.0
placementrequiredobjectAdCOM 1.0
item.idrequiredstringmust match the element ID (div) associated with the corresponding GPT ad slot
item.placement.tagidoptionalstringhow the slot will be presented in APS reporting

APS slot definition legacy

ParameterRequiredTypeDescription
slotsrequired[object]a collection of slot definitions
slotIdrequiredstringmust match the element ID (div) associated with the corresponding GPT ad slot
slotNameoptionalstringhow 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();
    });
  });