prebid / Prebid.js

Setup and manage header bidding advertising partners without writing code or confusing line items. Prebid.js is open source and free.
https://docs.prebid.org
Apache License 2.0
1.28k stars 2.05k forks source link

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

Closed ialex closed 8 years ago

ialex commented 8 years ago

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

mkendall07 commented 8 years ago

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.

ialex commented 8 years ago

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

mkendall07 commented 8 years ago

@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.

ialex commented 8 years ago

@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);
nickjacob commented 8 years ago

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];
});
protonate commented 8 years ago

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.

BartVB commented 8 years ago

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

protonate commented 8 years ago

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