> For the complete documentation index, see [llms.txt](https://docs.relevant-digital.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.relevant-digital.com/technical/integration/advanced-implementation-patterns/edit-bidder-parameters-in-pbjs.adunit.md).

# Edit bidder parameters in \`pbjs.adUnit\`

## **Overview**

This article outlines a method by which a publisher can modify the pbjs.adUnit object for any given bidder, for example to pass bidder parameters that are not commonly used or are tied to data available on the publishers site.

In this example we can use the [onAuctionInitDone](https://help.relevant-digital.com/knowledge/relevantdigital.loadprebid) callback, invoked once all the placements are setup and before the auction has commenced, to intercept the pbjs.adUnit object that will be set and modify it.

In the example below we push custom [placement data](https://help.relevant-digital.com/knowledge/adding-placement-tag-fields) 'keywords' to the appneuxs '[keywords' bid parameter.](https://docs.prebid.org/dev-docs/bidders/appnexus.html)

### **Code**

```
relevantDigital.addAuctionCallbacks({
    onAuctionInitDone: ({ auction }) => {
        auction.usedUnitDatas.forEach((unitData) => {
            const { adUnit, pbAdUnit } = unitData;
            const value = adUnit.data.keywords;
            if (value) {
                pbAdUnit.bids.forEach((bid) => {
                    if (bid.bidder === "appnexus") {
                        bid.params.keywords = {"key": value}
                    }
                })
            }
        })
    },
})
```

## **Walk-through**

Opposed to demonstrating the usecase in relevantDigital.loadPrebid(), the code is using [relevantDigital.addAuctionCallbacks](https://help.relevant-digital.com/knowledge/relevantdigital.addauctioncallbacks) instead. The addAuctionCallbacks function is useful for implementing callback functions in scenarios where it may not be possible to edit relevantDigital.loadPrebid().

[onAuctionInitDone](https://help.relevant-digital.com/knowledge/relevantdigital.loadprebid) callback is invoked once all the placements are setup and before the auction has commenced, to intercept the pbjs.adUnit object that will be set and modify it. onAuctionInitDone exposes an 'auction' object, from which we can retrieve 'adUnit' & 'pbAdUnit' data.

The 'adUnit' data is all the information on the placement that is set in the Relevant Yield UI. This then includes any 'custom' data that may have been assigned to the placement through the use of the placement tag fields.

The 'pbAdUnit' data is essentially what will become the pbjs.adUnit object, the object that is required by pbjs for a placement to be included in the prebid auction.

In the above example we retrieve 'keywords' custom data from the adUnit.data, and then appned it to the pbAdUnit if certain conditions are met.

These conditions are that pbAdUnit.bid.bidder is appnexus & adUnit.data.keywords is defined.

If these conditions are met then 'value' (the custom data of adUnit.data.keywords) is appended to the bid.params for that given bidder (appnexus) in the auction.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.relevant-digital.com/technical/integration/advanced-implementation-patterns/edit-bidder-parameters-in-pbjs.adunit.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
