Prebid.js icon indicating copy to clipboard operation
Prebid.js copied to clipboard

Read the slots on the page to ask just for those bids?

Open ialex opened this issue 10 years ago • 8 comments

Invoking Prebid Masters

I have been implementing a lot of sites lately and some publishers have an insane amount of ad units which makes it hard to maintain one configuration per page depending on the ad units on that page, i was reading a script from OpenX http://wkm-d.openx.net/w/1.0/jstag?nc=1001908-FileHippo and they don't have the Slots hardcoded but somehow read them from the page or from the googletag.cmd queue maybe?

Would it be possible to implement something like this on Prebid? i cannot figure it out how they do it on their script http://wkm-d.openx.net/w/1.0/jstag?nc=1001908-FileHippo

ialex avatar Apr 27 '16 16:04 ialex

Hi @ialex We decided against this approach because it requires that the DFP configuration & library loading to be done before invoking prebid and loading bidders. That would increase latency on the page quite a bit. So while it is possible, it doesn't seem like a good approach. Let me know if you have a better solution to the problem.

mkendall07 avatar Apr 27 '16 19:04 mkendall07

Using the new setup with the option to disableInitialLoad() what we would need to read the slots before we add the adUnits?

i guess we can define before we create the adUnits objects then use googletag.pubads().getSlots() to read the slots to filter the adUnits array

ialex avatar Apr 27 '16 19:04 ialex

@ialex Yes even with disableInitialLoad function, it still has a good chance to increase latency. Do you have any API proposal for this? How would the bidders be configured? I'll leave this open as a feature request but it's not a high priority for us at this time.

mkendall07 avatar May 03 '16 12:05 mkendall07

@mkendall07

For now I'm adding an array before the prebid setup to filter the ad units before they are added so we remove the ones not needed for the page and that will allow me to have just one config for all pages but remove not needed ones with a single array

var runAdUnits = ['/1212/some_adunit', '/1212/some_adunit_2'];

if (runAdUnits) {
    adUnits = adUnits.filter(function (adUnit) {
      return runAdUnits.indexOf(adUnit.code) !== -1;
    });
  }
  window.pbjs.addAdUnits(adUnits);

ialex avatar May 03 '16 14:05 ialex

what if you add an event before https://github.com/prebid/Prebid.js/blob/master/src/adaptermanager.js#L15, like the CPM adjustment,

// prbly a better name than this
events.emit('checkAdUnitStatus', adUnit);
if (adUnit.disabled === true) return; // the event handler would have to set this to true
return adUnit.bids.filter(bid => bid.bidder === bidderCode)

integration for publisher:

var definedSlots = slotsMappedByName(googletag.pubads().getSlots());
pbjs.onEvent('checkAdUnitStatus', function (adUnit) {
  adUnit.disabled = !definedSlots[adUnit.id];
});

nickjacob avatar May 20 '16 16:05 nickjacob

I believe that this use case can be accommodated with #386 in that each grouping of placements would be an auction and you will be able to initiate multiple auctions.

protonate avatar Jun 07 '16 20:06 protonate

It would be easier to cleanly solve this problem when information about DFP ads was available to Prebid.js. This might help: #398

BartVB avatar Jun 09 '16 06:06 BartVB

Closing as answered with #398 -- this can be done within an implementation rather than a part of prebid core.

protonate avatar Aug 18 '16 22:08 protonate