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

Setting a maximum bid

Open dmsinger opened this issue 10 years ago • 3 comments

Looking at the custom bucket example and docs here: http://prebid.org/dev-docs/examples/custom-price-bucket.html and here: http://prebid.org/dev-docs/publisher-api-reference.html#module_pbjs.bidderSettings

I'm trying to put together the simplest way to define a maximum bid.

For the sake of example, let's say we only have line items up to $11.00. I want to make sure anything below that is set to 11.00.

I need to adjust most bids (net/gross or currency exchange). So I was wondering if this would do the trick:

        pbjs.bidderSettings = {
            // all my one-by-one partner adjustments,
            standard: {
                adserverTargeting: [{
                    key: "hb_pb",
                    val: function(bidResponse) {
                        var cpm = bidResponse.cpm;
                        if (cpm > 11.00) {
                          return '11.00';
                        }
                    }
                }]
            }
        }

dmsinger avatar Aug 15 '16 18:08 dmsinger

@dmsinger I think this would do what you want:

if (cpm >= 11.00) {
  return '11.00';
}
else{
  //use mechanism to round price
  return bidResponse.pbMg;
}

Choice the appropriate rounding you want in the else statement with using pbLg, pbMg, pbHg

mkendall07 avatar Aug 15 '16 19:08 mkendall07

Thanks, looks good. Just need to reverse the => to >= (or just keep it to > if 11.00 is set).

dmsinger avatar Aug 15 '16 22:08 dmsinger

I get this error:

ERROR: Error trying to write ad Id : to the page. Missing document or adId

Edit: I had to add both hb_adid, and hb_bidder to adserverTargeting.

dmsinger avatar Aug 15 '16 22:08 dmsinger