Setting up Header Bidding
- Each monetizer to be connected has a separate contract for bidding using Header Bidding technology.
- An ad unit is created in the monetizer's personal account.
To start external monetization, complete all the configuration steps. Make sure that a link to the monetizer is traced for a number of objects:

- Create a template for the monetizer N in the banner type.
- Specify the external monetizer N in the campaign parameters.
- Create a banner with the monetizer N template in the campaign.
- Embed a script with settings for bid requests sent from placements to the monetizer N on the site.
Step 1. Set up an Adfox account
- Determine the types of banners to place buyers on. If necessary, create new banner types.
Add templates for Header Bidding external monetizers to the banner types:
- Go toand click
next to the banner type you need.
- Click Use preset and add templates for bidders, which are named as follows:
Header Bidding {buyer name} [context]
For monetizers working via Adfox HB, select the Header Bidding Adfox [context] template.
- Determine the placements for bidders. If necessary, create new ones.
- Add one campaign per buyer:
- Fill in the Name and Advertiser fields as you wish.
- Select a buyer in the External monetizer parameter.
For monetizers working via Adfox HB, specify the ID of the buyer's account in Adfox (
ownerId
). You can find it out from the monetizer or in the monetizer's ad tag.Example of ownerId in the ad tagNote. The CPM is set in the monetizer's account. If your account is an Adfox HB monetizer, you can set separate CPMs for flights and placements within your campaign. To learn more, contact the Adfox support service.
- After the campaign is added, the Placement tab opens. Enable the campaign placement and click Change.
Open the campaign settings, go to the Banners tab, and select the banner type you need. The list will only contain banner types that contain templates for the buyer selected in the campaign parameters.
- Select the template you need on the Banner contents tab.
- In the window with banner parameters, specify its name and click Add.
- After creating campaigns for all buyers, copy their IDs. You can find them in the ID column on the page with the list of campaigns. You'll need the IDs to set up a configuration script on the site.
Step 2. Create a configuration script
- Prepare an ad tag for a placement:
- If you haven't added an ad tag to the website yet, get one by following the instructions.
- If the tag is already embedded in the website, take it from the layout.
In the ad tag, find the
containerId
parameter and copy its value. You'll need the ID when creating a script. - Create a script using the HB configurator:You can also create a script manually following the instructions. With manual setup, you can add additional features like calling cookie-sync pixels.
- Go to.Important. The configurator is only available if you have campaigns with an external monetizer.
- Click Add container. Specify the Container ID: insert the
containerId
parameter value you copied earlier from the ad tag. - Select the type of ad request that you want to receive in this placement: Banner, Combo, InPage, or InStream.For the Banner type:
- Click Add bidder.
- Specify the banner's width and height in pixels. For example, [300, 300].
- Select a buyer and specify the Buyer's placement ID.
- In the User Timeout field, specify the waiting time for a response from the bidder's server in milliseconds.
- The Trusted Owners field is optional. If you plan to send bids to other Adfox account requests via the Adfox code forwarding [loader] template, specify the IDs of the accounts where the codes are forwarded from, separating them by commas.
Click Generate. After the script appears in the field on the right, click Copy.
Example of filling in parameters for a monetizer working via Adfox HB
Step 3. Place the script on the website
To place the script that you have set up:
- Add the script created in the HB configurator to the
head
of the website page. Make sure that the ad loader code is only embedded once.Example of embedding a script<head> <script src="https://yandex.com/ads/system/header-bidding.js" async></script> <script> var adfoxBiddersMap = { criteo: '710398', adriver: '737037 }; var adUnits = [ { code: 'adfox_1', bids: [ { bidder: 'criteo', params: { placementId: 917087 } } ] }, { code: 'adfox_2', sizes: [[ 728, 90 ]], bids: [ { bidder: 'criteo', params: { placementId: 917087 } }, { bidder: 'adriver', params: { placementId: 762890 } } ] } ]; var userTimeout = 500; window.YaHeaderBiddingSettings = { biddersMap: adfoxBiddersMap, adUnits: adUnits, timeout: userTimeout }; </script> <script>window.yaContextCb = window.yaContextCb || []</script> <script src="https://yandex.com/ads/system/context.js" async></script> </head>
Embed an ad unit's ad tag in the place where you want to serve ads. If you already added an ad tag to your website, don't change it.
- Embed the
header-bidding.js
script in thehead
of the website page.<script src="https://yandex.com/ads/system/header-bidding.js" async></script>
- Add the manually created script under the
header-bidding.js
script. - Insert the ad loader code to the
head
of the page, too, under the Header Bidding settings. If the ad loader code was inserted earlier, move it below theheader-bidding.js
settings. That way, the loader can determine that the page contains Header Bidding and identify which ads are to wait for bids.<script>window.yaContextCb = window.yaContextCb || []</script> <script src="https://yandex.com/ads/system/context.js" async></script>
Example of embedding a script<head> <script src="https://yandex.com/ads/system/header-bidding.js" async></script> <script> var adfoxBiddersMap = { criteo: '710398', adriver: '737037 }; var adUnits = [ { code: 'adfox_1', bids: [ { bidder: 'criteo', params: { placementId: 917087 } } ] }, { code: 'adfox_2', sizes: [[ 728, 90 ]], bids: [ { bidder: 'criteo', params: { placementId: 917087 } }, { bidder: 'adriver', params: { placementId: 762890 } } ] } ]; var userTimeout = 500; window.YaHeaderBiddingSettings = { biddersMap: adfoxBiddersMap, adUnits: adUnits, timeout: userTimeout }; </script> <script>window.yaContextCb = window.yaContextCb || []</script> <script src="https://yandex.com/ads/system/context.js" async></script> </head>
Embed an ad unit's ad tag in the place where you want to serve ads. If you already added an ad tag to your site, don't change it.
If the code reload function (the reload method) is used for a container, a repeated request is sent to all the buyers specified for this container in the adUnits object when reloading it.
For websites with infinite content loads, including placements, that require that you make new requests to buyers, use a solution for websites with “infinite” scroll.
<head>
<script src="https://yandex.com/ads/system/header-bidding.js" async></script>
<script>
window.YaHeaderBiddingSettings = {
biddersMap: {
criteo: '710398',
adriver: '737037',
hpmd: '737040',
adfox_example: '168627'
},
adUnits: [
{
code: 'adfox_1',
bids: [
{
bidder: 'criteo',
params: { placementId: 917087 }
}
]
},
{
code: 'adfox_2',
sizes: [[ 728, 90 ]],
bids: [
{
bidder: 'criteo',
params: { placementId: 917087 }
},
{
bidder: 'adriver',
params: { placementId: 762890 }
},
{
bidder: 'adfox_example',
params: { p1: 'bxzlm', p2: 'ekwz' }
}
]
},
{
code: 'adfox_3',
bids: [
{
bidder: 'hpmd',
params: { placementId: '2360' }
}
]
}
],
timeout: 500
};
</script>
<script>window.yaContextCb = window.yaContextCb || []</script>
<script src="https://yandex.com/ads/system/context.js" async></script>
</head>
<body>
<div id="adfox_1"></div>
<script>
window.yaContextCb.push(()=>{
Ya.adfoxCode.create({
ownerId: 255196,
containerId: 'adfox_1',
params: { pp: 'g', ps: 'cnsf', p2: 'frnp' }
})
})
</script>
<div id="adfox_2"></div>
<script>
window.yaContextCb.push(()=>{
Ya.adfoxCode.create({
ownerId: 255196,
containerId: 'adfox_2',
params: { pp: 'g', ps: 'cnsh', p2: 'frnq' }
})
})
</script>
<div id="adfox_3"></div>
<script>
window.yaContextCb.push(()=>{
Ya.adfoxCode.create({
ownerId: 255196,
containerId: 'adfox_3',
params: { pp: 'g', ps: 'cnsh', p2: 'frny' }
})
})
</script>
</body>
Examples of embedding scripts and setting up a configuration script:
<script src="https://yandex.com/ads/system/header-bidding.js" async></script>
<script>
window.YaHeaderBiddingSettings = {
biddersMap: { buzzoola: '776727', betweenDigital: '1114942' },
adUnits: [
{
code: 'adfox_156536764866112926',
codeType: 'inpage,
bids: [
{ bidder: 'buzzoola', params: { placementId: '296669' } },
{ bidder: 'betweenDigital', params: { placementId: '3263439' } }
]
}
],
timeout: 1000
};
</script>
<script>window.yaContextCb = window.yaContextCb || []</script>
<script src="https://yandex.com/ads/system/context.js" async></script>
<script src="https://yandex.com/ads/system/header-bidding.js" async></script>
<script>
window.YaHeaderBiddingSettings = {
biddersMap: { buzzoola: '776727', betweenDigital: '1114942' },
adUnits: [
{
code: 'adfox_156536764866112926',
codeType: 'combo',
bids: [
{ bidder: 'buzzoola', params: { placementId: '296669' } },
{ bidder: 'betweenDigital', params: { placementId: '3263439' } }
]
}
],
timeout: 1000
};
</script>
<script>window.yaContextCb = window.yaContextCb || []</script>
<script src="https://yandex.com/ads/system/context.js" async></script>
<script src="https://yandex.com/ads/system/header-bidding.js" async></script>
<script>
window.YaHeaderBiddingSettings = {
biddersMap: { adriver: '776690', betweenDigital: '1114942' },
adUnits: [
{
code: 'adfox_156536764866112926',
codeType: 'instream,
bids: [
{
bidder: 'adriver',
adBreakTypes: ['preroll','midroll'],
params: { placementId: '5534564' }
},
{
bidder: 'betweenDigital',
adBreakTypes: ['preroll', 'midroll', 'postroll'],
params: { placementId: '3575996' }
}
]
}
],
timeout: 1500
};
</script>
<script>window.yaContextCb = window.yaContextCb || []</script>
<script src="https://yandex.com/ads/system/context.js" async></script>