Skip to content

Multi-Format

APS offers a solution that enables you to make a single request for both a Display and Outstream bid, with the highest bid being returned. This is known as a multi-format slot. The Outstream component of the multi-format slot is powered by the APS-provided video player, aps_video_player.

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
item.placement.video.ptypeoptionalintegerspecifies video subtype

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
mediaTyperequiredstringmust be set to multi-format
multiFormatPropertiesrequiredobjectmust specify display and video params
js
// define slots
aps.record("ad/slot/define", {
  item: [
    {
      id: "div-slot-1", // must be defined within APS dashboard
      spec: {
        placement: {
          tagid: "name-for-reporting",
          sdk: "aps_video_player",
          display: {
            displayfmt: [{ w: 300, h: 250 }],
          },
          video: {
            ptype: 4, // 2, 3, 4, or 5
            w: 300,
            h: 250,
          },
        },
      },
    },
  ],
});
// define slots
aps.record("ad/slot/define", {
  item: [
    {
      id: "div-slot-1", // must be defined within APS dashboard
      spec: {
        placement: {
          tagid: "name-for-reporting",
          sdk: "aps_video_player",
          display: {
            displayfmt: [{ w: 300, h: 250 }],
          },
          video: {
            ptype: 4, // 2, 3, 4, or 5
            w: 300,
            h: 250,
          },
        },
      },
    },
  ],
});
js
// define slots
aps.record("ad/slot/define", {
  slots: [
    {
      slotID: "div-slot-1", // must be defined within APS dashboard
      slotName: "name-for-reporting",
      mediaType: "multi-format",
      multiFormatProperties: {
        display: {
          sizes: [
            [300, 250],
            [320, 50],
          ],
        },
        video: {
          sizes: [[300, 250]],
        },
      },
    },
  ],
});
// define slots
aps.record("ad/slot/define", {
  slots: [
    {
      slotID: "div-slot-1", // must be defined within APS dashboard
      slotName: "name-for-reporting",
      mediaType: "multi-format",
      multiFormatProperties: {
        display: {
          sizes: [
            [300, 250],
            [320, 50],
          ],
        },
        video: {
          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();
    });
  });