---
updatedAt: 2026-07-27T10:08:33.000Z
agentTools:
  projectIndex: https://developers.dailymotion.com/v0/llms.txt
---

# Header bidding

Optimize the Dailymotion Player for header bidding solutions.

## Introduction

The Dailymotion Player enables you to know when an ad slot is ready to be filled during a video session. In this guide, we'll show you how to implement the right parameters to **optimize for header bidding solutions all ad slots available in the Player.**

<Callout icon="📘" theme="info">
  ### Note:

  Only available when embedding the Player via the <Anchor target="_blank" href="https://developers.dailymotion.com/v0/docs/player-embed-script-web">Embed Script</Anchor> or the <Anchor target="_blank" href="https://developers.dailymotion.com/v0/docs/player-library-script">Library Script</Anchor> as access to the Platform API is required.
</Callout>

***

## Implementation steps

<br />

### 1. Allow your player to work with your Prebid solution

The Player setting [`enable_wait_for_custom_config`](https://developers.dailymotion.com/reference/player-fields#enable_wait_for_custom_config) allows the Player to work more efficiently with advertising solutions such as Prebid.

This setting can be activated from the Dailymotion Studio or via the API. You can either create a new Player configuration, or updating an existing one.

<Tabs>
  <Tab title="From the Dailymotion Studio">
    <ol>
      <li>Log into your <a href="https://www.dailymotion.com/partner/embed/players/"><b>Dailymotion Studio</b></a>, go to <b>Embeds > Players</b> and open the Player you want to edit, or create a new one.</li>
      <li>In the Player configuration interface, scroll down to the <a href="https://faq.dailymotion.com/hc/en-us/articles/4408224350994#advertising"><b>Advertising</b></a> section, and toggle on <b>“Wait for customConfig”</b>.</li>
      <li><b>Save</b> your configuration and <b>copy the Player ID</b>.</li>
    </ol>
  </Tab>

  <Tab title="From the API">
    ```
    // Enable the parameter enable_wait_for_custom_config on an existing Player
    // Replace <YOUR_PLAYER_ID> with the Player ID you want to modify

    curl -X POST -H 'Authorization: Bearer ${ACCESS_TOKEN}' \
       -d 'enable_wait_for_custom_config=true' \
       'https://api.dailymotion.com/player/<YOUR_PLAYER_ID>'
    ```
  </Tab>
</Tabs>

<br />

**Once the Player setting is enabled:**

* The Player ad values can be updated during the current video session.
* The new Player event `AD_READYTOFETCH` becomes accessible via the SDK and signals when an ad is about to play (see step 5).

<br />

### 2. Embed a Player with the associated Player ID

You can now embed on your webpage the Player from step 1 and your video.

```
// Replace {Player_ID} and {Video_ID} with your own

<script
  src="https://geo.dailymotion.com/player/{Player_ID}.js"
  data-video="{Video_ID}" id="myPlayer"
></script>
```

<br />

### 3. Get the Player and fetch ad values

Using `Promise.all([...])`, run both promises in parallel: `getPlayer()` to retrieve your Player, and your first Prebid request for your Pre-roll.

<Callout icon="📘" theme="info">
  ### Note:

  When used with a first preroll, `myFetchPrebid` function shouldn’t trigger a prebid auction since it is already ongoing. It should however trigger the auction for any other ad break.
</Callout>

```
// Replace myFetchPrebid() with your own Prebid request 

Promise.all([dailymotion.getPlayer('myPlayer'), myFetchPrebid()])
  .then(([player, customConfig]) => {
```

<br />

### 4. Update the Player with retrieved ad values

Once both promises are successfully resolved – meaning that the Player is retrieved and the ad values are returned – you can update the Player for your first Pre-roll with the ad values from `setCustomConfig()`.

```
player.setCustomConfig(customConfig)
```

<br />

### 5. Add an event listener for the next ads

By enabling the Player setting `enable_wait_for_custom_config` in step 1, you have access to the ad event [`AD_READYTOFETCH`](https://developers.dailymotion.com/reference/web-sdk-player-events#ad_readytofetch) which is sent a few seconds before an ad is supposed to play.

After the event is sent, the Player will wait before sending the ad request. By default, the Player waits 6 seconds before each ad position. You can also set a custom delay (between 1 and 10 seconds) using `wait_for_custom_config_delay`.

Add <Anchor target="_blank" href="https://developers.dailymotion.com/v0/reference/web-sdk-player-events#ad_readytofetch">AD\_READYTOFETCH</Anchor> to your integration to know when a new ad is about to play. Each time it is caught, you can update the advertising values sent to your header bidding solution and pass them to the Player using [`setCustomConfig()`](https://developers.dailymotion.com/reference/web-sdk-player-methods#advertising-web).

```
player.on(dailymotion.events.AD_READYTOFETCH, (state) => {
      myFetchPrebid(state)
        .then((customConfig) => {
          player.setCustomConfig(customConfig)
        })        
```

<br />

### Optional: Skip request on specific ad positions

If you don't want to make header bidding calls for midrolls and/or postrolls, you can set an empty value in `setCustomConfig({})` when listening to a specific ad position with `AD_READYTOFETCH`.

**Code sample:**<br />In the following example, if the event `AD_READYTOFETCH` detects a midroll, no header bidding request is triggered. If it detects any other ad slot (postroll or subsequent preroll), a header bidding request will be made.

```
player.on(dailymotion.events.AD_READYTOFETCH, state => {
	if (state.adPosition === 'midroll') {
		player.setCustomConfig({}) // skip
	} else {
		myFetchPrebid(state)
			.then(customConfig => {
				player.setCustomConfig(customConfig)
			})
			.catch(err => {
				console.error(err)
			})
	}
})
```

<br />

***

## Code sample

The following code sample implements the steps described above:

<HTMLBlock>{`
<iframe height="650" style="width: 100%;" scrolling="no" title="[Player Embed Script] - working with Header Bidding" src="https://codepen.io/team/dailymotion-developer/embed/mdQzjEG?default-tab=js&theme-id=40175" frameborder="no" loading="lazy" allowtransparency="true" allowfullscreen="true">See the Pen <a href="https://codepen.io/team/dailymotion-developer/pen/mdQzjEG"> \[Player Embed Script] - working with Header Bidding</a> by dailymotion-developer (<a href="https://codepen.io/team/dailymotion-developer">@dailymotion-developer</a>) on <a href="https://codepen.io">CodePen</a>.</iframe>
`}</HTMLBlock>

<br />