> 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/hb-manager/setup/prebid-config-tag-fields-advanced.md).

# Prebid Config Tag Fields - Advanced

Using Prebid Config Tag Fields you can create custom settings in Yield to control site behavior. The settings are applied using JavaScript implemented in the site-code or via custom code in Yield.

In order to create custom settings per *placement* one can use [Placement Tag Fields](broken://pages/8f017c8d4044c912c7a0d23732447be75304cc4e) - while for settings that are not connected to individual placements - the **Prebid Config Tag Fields** page is used. This creates settings that are available *Globally*, per *Account*, per *Site* and *Prebid Configuration*.

The settings will be available from the **Prebid parameters** menu via the **Generic Prebid Config Data** section, except for in *Prebid Configurations* where it will be available directly in the **Configuration Data** section. For more information about the settings hierarchy in Yield, read about [**Prebid Parameters**](broken://pages/8b7006f574964243f6eb592104e02fba5bf61bf5).

*Example of such settings can be:*

* Extra .js files that should be loaded.
* Custom Prebid settings per site that can be applied e.g. by calling [relevantDigital.addPrebidConfig()](broken://pages/a9fffdd117fc36121adcb0140d78230f65b73bb2).
* ..and anything else that can be done via JavaScript including CSS-customization, etc.

The result of the settings is available in an object named **data** that is available directly via the *prebid configuration* and *auction* objects accessible via JavaScript. (the methodology is similar as for the **AdUnit.data** object created per placements when using [**Placement Tag Fields**](broken://pages/8f017c8d4044c912c7a0d23732447be75304cc4e))

### Creating the custom settings

This is done via the **Prebid Config Tag Fields** page:

![Pb config tag fields](/files/90218f55b27a7dc65d9321d2f709c2bbb95e1b69)

Settings can have different types such as *String*, *Number*, *Array* and *Object*. The example above shows a hypothetical setting that can be used to control which *Consent Management Platform* (CMP) that is loaded. In the example we enable **Options** for the string and add the available options using the **Edit** menu. This turns the setting into a selector with predefined values instead of a free-text field.

### Changing settings and using them from JavaScript

The screenshot below combines changing our new setting as well as implementing the code that is applying the setting on the site. (although the CMP-init code is just illustrated by console-messages..)

![Pb config tag fields apply (zoomed)](/files/31e50431c43b458df9ac249ca76a6a80e1f9f284)

To take action upon the settings - one option is to use **Custom Config JavaScript code** as above. But if you for example want to implement the behavior directly in the site-code instead - then it's possible via the [relevantDigital.addAuctionCallbacks()](broken://pages/4417303e71670e65c08b2323ba2734247fec8a59) function combined with the **onBeforeAuctionSetup** callback for [relevantDigital.loadPrebid()](broken://pages/b6fbef807cab617da8413b4bd54ece17dbc2dcc1).

```javascript
const loadCmp = (cmp) => {
    if (cmp === 'quantcast') {
        console.info('Load Quantcast CMP stub/init code here');
    } else if (cmp === 'onetrust') {
        console.info('Load OneTrust CMP stub/init code here');
    } else {
        console.info('No CMP');
    }
};
let hasLoadedCmp = false // We only want to load CMP once
window.relevantDigital = window.relevantDigital || {};
relevantDigital.cmd = relevantDigital.cmd || [];
relevantDigital.cmd.push(function() {
    relevantDigital.addAuctionCallbacks({
        onBeforeAuctionSetup: ({ auction }) {
            if (!hasLoadedCmp) {
                // 'auction.data' is the object with the selected Generic Prebid Config Data
                loadCmp(auction.data.cmp)
                hasLoadedCmp = true;
            }
       },
      });
});
```

#### Applying the settings in JavaScript before first call to relevantDigital.loadPrebid()

Depending on implementation it might take a while until the site code is ready to call **relevantDigital.loadPrebid()**. If you don't want to waste any time waiting for that, for example if you need to load other .js files - then a workaround is to trigger an *empty* auction by using an empty **allowedDivIds** array, like below:

```javascript
window.relevantDigital = window.relevantDigital || {};
relevantDigital.cmd = relevantDigital.cmd || [];
relevantDigital.cmd.push(function() {
    relevantDigital.loadPrebid({
        configId: '[CONFIG-ID]',
        allowedDivIds: [],
        noGpt: true,
    });
});
```


---

# 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/hb-manager/setup/prebid-config-tag-fields-advanced.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.
