relevantDigital.getAdUnitInstanceByBid()

This function is used for obtaining placement-information such as the ad slot from a Prebid.js bid object.

By using this function it's possible match a bid object obtained from e.g. a pbjs.onEvent() event handler to the right placement.It will return an object that contain, most importantly, a .slot member representing the ad slot.

When using GAM this object might be a googletag.Slot object, but when using instream video, delayedAdserverLoading or another ad server - it will instead be an own type with a similar (but much smaller) API. In particular, the slot object will always contain the following functions:

  • slot.getSlotElementId() - Will return the div-id of the ad slot, or in the case of instream video - the id supplied to relevantDigital.defineVideoSlots().
  • slot.getAdUnitPath() - The ad unit path / placement id.

Parameters

relevantDigital.getAdUnitInstanceByBid(bid)

Example

pbjs.onEvent('bidWon', (bid) => {
const instance = relevantDigital.getAdUnitInstanceByBid(bid);
  const { slot } = instance;
console.info('div id: ', slot.getSlotElementId());
console.info('placement id: ', slot.getAdUnitPath());
});