1

I am using prebid.js in order to do header bidding. My code is very simmilar to the example here:

http://prebid.org/dev-docs/examples/postbid.html

Starting from the row #11 in the example - I set adUnitBids, i.e. which demand tags will participate in the auction.

Once I have a winner in the auction (look at the line #64 in the example) I have params variable holding the auction result, e.g. {hb_size: "300x250", hb_pb: "0.70", hb_adid: "519325bc9adf98ef", hb_bidder: "appnexus"}

Now I want to know which tag won. Using the value of params.hb_bidder == "appnexus" I can go through adUnitBids and find the one with bidder == "appnexus". It's not a very illegant solution, but it makes the work done.

The issue starts wen there are more than one tag of the same partner, e.g.:

var adUnitBids = [ { bidder: 'appnexus', params: { placementId: '10433394' } }, { bidder: 'appnexus', params: { placementId: '123' } }, ]

I will know that appnexus won, but not which of the tags (even the index in adUnitBids array would be totally enough for me).

I looked through the list of the available methods in Prebid.js documentation and couldn't find one that can help me with this issue.

Any solution? Thank you in advance.

Alexander
  • 7,484
  • 4
  • 51
  • 65

1 Answers1

0

Try looking at the onEvent events. This should get you information about the winning adunits as they are fired off from pbjs.renderAd

The bidWon, bidRequested and bidResponse events are unique in that additional data is passed and can be passed in your inline function:

pbjs.que.push(function() {
    pbjs.onEvent('bidWon', function(data) {
        console.log(data);
    });
});
Andrew Bowman
  • 798
  • 9
  • 21