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

Inject a mock bid #12261

Closed EskelCz closed 1 hour ago

EskelCz commented 5 days ago

Type of issue

Question

Description

Is there a way to inject my own testing bid via the debugging module? I know about intercept, but that just changes the current bids. In ad ops there are many issues downstream (in rendering) that often need fixing/testing before we start getting bids, and that leaves us stuck. It would save us a lot of time/work to have such capability.

I have found some discussion on the topic here, but can't find if it resulted in anything real: https://github.com/prebid/Prebid.js/issues/4461

Thanks for consideration.

dgirardi commented 1 day ago

In ad ops there are many issues downstream (in rendering) that often need fixing/testing before we start getting bids, and that leaves us stuck. It would save us a lot of time/work to have such capability.

You can use intercept to inject any creative (then: {ad: ...}, or adUrl). Otherwise could you elaborate on what you're trying to do?

patmmccann commented 1 day ago

@EskelCz it seems we should add an example forced bid to this page: https://docs.prebid.org/dev-docs/modules/debugging.html#replace-rules

Are you looking for an example to change the bidder of an existing response?

Do you need a banner example of Image

EskelCz commented 1 day ago

@patmmccann Banner example would be a good addition. But from my understanding the intercept system has two limitations:

  1. It cannot change the bidder (At least when I tried that I got a warning, something about using an unsupported alias for the bidder)
  2. It can only change received bids, not add anything new in a situation when I am not receiving ANY bids. Is this correct?

I have worked around this using magnite demand simulator or other tools to mock network requests, but it's not a convenient. Prebid debugging code can be more easily shared with a third party for example.

dgirardi commented 22 hours ago

It can only change received bids, not add anything new in a situation when I am not receiving ANY bids. Is this correct?

It works by intercepting bid requests and mocking the normal adapter request/response flow (but I realize now that the documentation is not clear on this). Stylized, the normal flow is:

  1. Ad unit definitions are transformed into bid requests (for each ad unit, a bid request for each of its .bids)
  2. Bid requests are filtered through adapters' isBidRequestValid
  3. Valid bid requests are transformed to network requests via adapters' buildRequests
  4. Network responses are transformed to bid responses via adapters' interpretResponse

When an intercept rule matches a bid request, steps 3 and 4 are skipped, and to the rest of Prebid it looks like the adapter's interpretResponse replied with the object generated from then.

So you should be able to use it to simulate a bid when the actual exchange won't bid. The limitation is that you need a bid request to start with (but you can always just add another entry in .bids), and it needs to pass normal validation.

EskelCz commented 1 hour ago

@dgirardi Ok thanks for the explanation. Not sure why it didn't work for me. I'll close this for now and maybe reopen once I come across it again and have some details to share.