---
metadata:
  - name: generator
    content: Diplodoc Platform v5.50.6
alternate:
  - https://yandex.com/support/adfox/en/monetization/script-setup.md
  - https://yandex.com/support/adfox/ru/monetization/script-setup.md
---
> **Documentation Index:** Fetch the complete configuration index at https://yandex.com/support/adfox/en/llms.txt

# Creating and placing a script on the site

## Creating a configuration script {#create}

1. Prepare an ad tag for an ad placement:
    - If you haven't added an ad tag to the site yet, get one by following the [instructions](https://yandex.com/support/adfox/en/ad-inventory/codes/get-code.md#site-code).
    - If the tag is already embedded on the site, 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.
    
1. Create a script using the [HB configurator](https://adfox.yandex.com/hbConfigurator.php):

    1. Go to **Monetization** → **HB configurator**.
    
        {% note info %}
    
        The configurator is only available if you have campaigns with an external monetizer.
    
        {% endnote %}
    
    1. Click **Add container**. Specify the **Container ID**: insert the `containerId` parameter value you copied earlier from the ad tag.
    1. Select the type of ad request that you want to receive in this placement: **Banner**, **Combo**, **InPage**, or **InStream**. For more information about connecting the **InStream** ad request type, see [Enabling InStream video ads](https://yandex.com/support/adfox/en/monetization/instream.md).
    
        {% note warning %}
    
        From monetizers integrated with the Prebid library, only **banner** ads are available.
    
        {% endnote %}
    
    1. Click **Add monetizer**.
    1. Specify the banner width and height in pixels: for example, `[300, 300]`. This parameter is mandatory for Prebid monetizers and some Yandex Header Bidding monetizers.
    1. Select monetizers and specify their parameters:

        - For Yandex Header Bidding monetizers, specify the **Monetizer's placement ID** (`Placement ID`). You can find the `Placement ID` in the monetizer interface.

          {% cut "Table with Yandex Header Bidding monetizer data" %}

          **Monetizer** | **Monetizer key** | `sizes` **parameter support** | **InStream video** | **[Combo](*combo)**\* **support (to learn more, see below)** | **The placement parameter in** `params`
          ----- | ----- | ----- | ----- | ----- | -----
          Adlook | adlook | no | yes | yes | `placementId`
          AdMile | admile | yes | yes | yes | `placementId`
          AdMixer | AdMixer | no | no | yes | `placementId`
          Adspector | adspector | yes | yes | yes | `placementId`
          Adtelligent | adtelligent | no | no | no | `placementId`
          Adwile | adwile | no | no | no | `placementId`
          Alfasense | alfasense | yes | no | no | `placementId`
          All in One Media | aio | no | no | no | `placementId`
          Astralab | astralab | yes | yes | yes | `placementId`
          A-traffic | atraffic | yes | yes | yes | `placementId`
          Between Digital | betweenDigital | yes | yes | yes | `placementId`
          Bidvol | bidvol | yes | yes | yes | `placementId`
          Buzzoola | buzzoola | yes | yes | yes | `placementId`
          Criteo | criteo | no | no | yes | `placementId`
          DGT SSP | dgt_ssp | no | no | no | `placementId`
          Digital Caramel | digitalcaramel | yes | yes | yes | `placementId`
          Dynotech | dynotech | yes | no | no | `placementId`
          Fotostrana | fotostrana | no | no | no | `placementId`
          GetIntent | getintent | no | no | no | `placementId`
          Gnezdo | Gnezdo | no | yes | no | `placementId`
          GPMAds | gpmads | yes | yes | yes | `placementId`
          Hybrid | hybrid | yes | no | yes | `placementId`
          Hyper AdTech | hyper | yes | yes | yes | `placementId`
          Kadam | Kadam | no | no | no | `placementId`
          Link | link | yes | yes | no | `placementId`
          Luxup | luxup | yes | yes | yes | `placementId`
          Market-place.su | marketplace | yes | no | no | `placementId`
          Media Instinct Group | mit | no | no | yes | `placementId`
          MediaSniper | mediasniper | yes | yes | yes | `placementId`
          Mediatoday | mediatoday | no | no | no | `placementId`
          MTS | mts | no | yes | yes | `placementId`
          MyTarget | myTarget | no | no | yes | `placementId`
          Native Rent | nativerent | no | no | no |`placementId`
          NEMEDIA | nemedia | no | yes | yes | `placementId`
          OHMYBID | ohmybid | yes | yes | yes | `placementId`
          Otclick HB | otclick | yes | yes | yes | `placementId`
          OTM | otm | no | yes | no | `placementId`
          Punch Media | punchmedia | yes | yes | yes | `placementId`
          Redllama | redllama | no | no | no | `placementId`
          Relap | relap | no | no | no | `placementId`
          Roxot | roxot | yes | yes | yes | `placementId`
          Sape | sape | yes | yes | yes | `placementId`
          SberAds | sberads | no | no | no | `placementId`
          Segmento | segmento | yes | yes | yes | `placementId`
          SlickJump | slickjump | no | yes | yes | `placementId`
          SMI2 | smi2 | no | yes | yes | `placementId`
          Soloway | adriver | yes | yes | yes | `placementId`
          Solta | solta | yes | yes | yes | `placementId`
          Sparrow | sparrow | yes | no | yes | `placementId`
          TechDig | techdig | yes | yes | yes | `placementId`
          UMG | umg | yes | yes | yes | `placementId`
          Upravel | upravel | yes | yes | no | `placementId`
          Videohead | videohead | yes | yes | yes | `placementId`
          Videonow | videonow | no | no | yes | `placementId`
          Viqeo | viqeo | yes | yes | yes | `placementId`

          {% endcut %}

        - For monetizers integrated with the Prebid.js library, the set of mandatory and optional parameters is different. The list of mandatory parameters depending on the monetizer is given in the table below.

          {% cut "Table with Prebid monetizer data" %}

          **Monetizer** | **Monetizer key** | **Required parameters** | **Optional parameters**
          ----- | ----- | ----- | -----
          AdformOpenRTB | pb_adf | `mid` (integer)<br/><br/>`inv` (integer)<br/><br/>`mname` (string) | [adf_prebid.org](https://docs.prebid.org/dev-docs/bidders/adf.html)
          AdKernel | pb_adkernel | `host` (string)<br/><br/>`zoneId` (integer) | [adkernel_prebid.org](https://docs.prebid.org/dev-docs/bidders/adkernel.html)
          AdRiver | pb_adriver | `siteid` (integer)<br/><br/>`placementId` (string) | [adriver_prebid.org](https://docs.prebid.org/dev-docs/bidders/adriver.html)
          AlgoriX | pb_algorix | `sid` (string)<br/><br/>`token` (string) | [algorix_prebid.org](https://docs.prebid.org/dev-docs/bidders/algorix.html)
          AppNexus	| pb_appnexus	| `placementId` (integer) |	[appnexus_prebid.org](https://docs.prebid.org/dev-docs/bidders/appnexus.html)
          Between Digital | pb_between | `s` (string) | [between_prebid.org](https://docs.prebid.org/dev-docs/bidders/between.html)
          CPMStar | pb_cpmstar | `placementId` (integer) | [cpmstar_prebid.org](https://docs.prebid.org/dev-docs/bidders/cpmstar.html)
          Criteo | pb_criteo | `networkId` (integer)<br/><br/>`pubid` (string) | [criteo_prebid.org](https://docs.prebid.org/dev-docs/bidders/criteo.html)
          Digitalcaramel | pb_digitalcaramel | `siteId` (string)<br/><br/>`placementId` (string) | [digitalcaramel_prebid.org](https://docs.prebid.org/dev-docs/bidders/digitalcaramel.html)
          Dvgroup | pb_dvgroup | `sspId` (string) | [docs_prebid.org](https://docs.prebid.org/dev-docs/bidders/dvgroup.html)
          fluct | pb_fluct | `tagId` (string)<br/><br/>`groupId` (string) | [fluct_prebid.org](https://docs.prebid.org/dev-docs/bidders/fluct.html)
          Getintent | pb_getintent | `pid` (integer) | [getintent_prebid.org](https://docs.prebid.org/dev-docs/bidders/getintent.html)
          Hybrid | pb_hybrid | `placeId` (string)<br/><br/>`placement` (string) | [hybrid_prebid.org](https://docs.prebid.org/dev-docs/bidders/hybrid.html)
          Index Exchange	| pb_ix	| `siteId` (string)	| [ix_prebid.org](https://docs.prebid.org/dev-docs/bidders/ix.html)
          Mediasniper | pb_mediasniper | `placementId` (string) | [mediasniper_prebid.org](https://docs.prebid.org/dev-docs/bidders/mediasniper.html)
          myTarget | pb_mytarget | `placementId` (string) | [mytarget_prebid.org](https://docs.prebid.org/dev-docs/bidders/mytarget.html)
          OneTag | pb_onetag | `pubId` (string) | [onetag_prebid.org](https://docs.prebid.org/dev-docs/bidders/onetag.html)
          OpenX	| pb_openx	| `delDomain` (string)<br/><br/>`unit` (string) | [openx_prebid.org](https://docs.prebid.org/dev-docs/bidders/openx.html)
          OperaAds | pb_operaads | `placementId` (string)<br/><br/>`endpointId` (string)<br/><br/>`publisherId` (string) | [operaads_prebid.org](https://docs.prebid.org/dev-docs/bidders/operaads.html)
          Programmatica | pb_programmatica | `siteId` (string)<br/><br/>`placementId` (string) | [programmatica_prebid.org](https://docs.prebid.org/dev-docs/bidders/programmatica.html)
          PubMatic | pb_pubmatic | `publisherId` (string) | [pubmatic_prebid.org](https://docs.prebid.org/dev-docs/bidders/pubmatic.html)
          Rich Audience | pb_richaudience | `pid` (string)<br/><br/>`supplyType` (string) | [richaudience_prebid.org](https://docs.prebid.org/dev-docs/bidders/richaudience.html)
          RTBHouse | pb_rtbhouse | `publisherId` (string)<br/><br/>`region` (string) | [rtbhouse_prebid.org](https://docs.prebid.org/dev-docs/bidders/rtbhouse.html)
          Rubicon Project	| pb_rubicon	| `accountId` (integer)<br/><br/>`siteId` (integer)<br/><br/>`zoneId` (integer) | [rubicon_prebid.org](https://docs.prebid.org/dev-docs/bidders/rubicon.html)
          Sape | pb_sape | `placeId` (integer) | [rtbsape_prebid.org](https://docs.prebid.org/dev-docs/bidders/rtbsape.html)
          Silverpush | pb_silverpush | `publisherId` (string) | [silverpush_prebid.org](https://docs.prebid.org/dev-docs/bidders/silverpush.html)
          Smaato | pb_smaato | `publisherId` (string)<br/><br/>`adspaceId` (string)<br/><br/>`adbreakId` (string) | [smaato_prebid.org](https://docs.prebid.org/dev-docs/bidders/smaato.html)
          Smart AdServer (Equativ) | pb_smartadserver | `siteId` (integer)<br/><br/>`pageId` (integer)<br/><br/>`formatId` (integer) | [smartadserver_prebid.org](https://docs.prebid.org/dev-docs/bidders/smartadserver.html)
          Smile Wanted | pb_smilewanted | `zoneId` (string) | [smilewanted_prebid.org](https://docs.prebid.org/dev-docs/bidders/smilewanted.html)
          Sovrn | pb_sovrn | `tagid` (string) | [sovrn_prebid.org](https://docs.prebid.org/dev-docs/bidders/sovrn.html)
          Teads | pb_teads | `pageId` (integer)<br/><br/>`placementId` (integer) | [teads_prebid.org](https://docs.prebid.org/dev-docs/bidders/teads.html)
          VOX | pb_vox | `placementId` (string)<br/><br/>`placement` (string) | [vox_prebid.org](https://docs.prebid.org/dev-docs/bidders/vox.html)
          

          {% endcut %}

          You can obtain all the necessary parameters in the monetizer interface.
    
        - For monetizers working via Adfox HB, specify the Adfox ad tag. The ad tag must be requested from the connected monetization platform.

          {% cut "Table with Adfox HB monetizer data" %}

          **Monetizer** | **Monetizer key** | `sizes` **parameter support in** `adUnits` | **Support InStream video** | **[Combo](*combo)**\* **support (to learn more, see below)** | **The placement parameter in** `params`
          ----- | ----- | ----- | ----- | ----- | -----
          Digital Alliance | adfox_imho-banners | no | yes | yes | variables from the `params` object of the monetizer ad tag
          Other monetizers that use Adfox HB | adfox_{owner_name}, where {owner_name} is the monetizer account name | no | no | yes | variables from the `params` object of the monetizer ad tag

          {% endcut %}

        {% note alert %}
        
        You can't combine monetizers that support combo with monetizers that don't in one placement. If you plan a mixed combo auction for your placement, only include monetizers that support combo. Bids from monetizers that don't support combo are ignored.
        
        {% endnote %}
    
    1. If there are multiple placements on the page, click **Add container**, specify the `containerId` of another placement, and add monetizers the same way.
    1. In the **User Timeout** field, specify the waiting time for a response from the monetizer's server in milliseconds.
    1. The **Trusted Owners** field is optional. If you plan to send bids to other Adfox account requests via the **Adfox code forwarding [context]** template, specify the IDs of the accounts the codes are forwarded from, separated by commas.
    1. Click **Generate**. After the script appears in the field on the right, click **Copy**.
    
1. If there are Prebid monetizers in the script, don't forget to install the [Prebid.js library](https://docs.prebid.org/download.html) and add a script with a library call.
1. Place the resulting script on the site.
    
    {% note warning %}

    - You can only embed a single Header Bidding config file in your site.
    - The [ad loader code](https://yandex.com/support/adfox/en/ad-inventory/codes/code-loader.md#js-code) shouldn't be repeated on the page and should be located below the script with Header Bidding settings. This way, the loader can determine that the page contains Header Bidding and identify which ads should wait for bids. If the loader code was installed earlier, delete the extra one.
    
    {% endnote %}
    
1. Embed an ad unit's ad tag in the place where you want to serve ads. If you already added an ad tag to the site, don't change it.


## Example of a single script for Yandex Header Bidding and Prebid.js {#prebid-example}


{% note info %}

For a detailed description of the script parameters, see below the example.

{% endnote %}


```html
<!-- Example of calling Prebid.js -->

<!-- Calling header-bidding.js -->

        
 

```


{% cut "Description of script parameters" %}

#|
||**Parameter** | **Description**||
|| `pbjs` | Prebid.js library API. A mandatory element if you connect monetizers integrated with Prebid.js. The parameter must be set to `pbjs`.

{% cut "For example" %}

```javascript
 var pbjs = pbjs || {};
 pbjs.que = pbjs.que || []; 
 ```
 
{% endcut %}

||
|| `biddersMap` | The object with `key`: `value` pairs, where:

- `key`: The monetizer key in single quotes. Monetizer keys can be found in the tables with monetizer data (see step 2.6 in the instructions above).

- `value`: The ID of the campaign created at the 11th Dynamic monetization level for the selected monetizer in single quotes.

{% cut "For example" %}

```javascript
'betweenDigital': '787336' 
```

{% endcut %}

||
|| `biddersCpmAdjustmentMap` | Optional parameter. The object with `key`: `value` pairs, where:

- `key`: The monetizer key in single quotes. Monetizer keys can be found in the tables with monetizer data (see step 2.6 in the instructions above).

- `value`: Multiplier applied to the monetizer's bids. With the multiplier, you can prioritize monetizers (for example, if one sends gross CPM and another sends net CPM).

  The value format is an integer or decimal number from 0 to 5 inclusive (up to three decimal places are supported).
||
|| `adUnits` | An array of objects with information about which monetizers to auction off ads to. It contains:

- **code**: The banner container ID (same as `containerId` in the Adfox ad tag).
- **codeType**: The type of ad request that you want to receive in this placement. Takes the following values:
   - `combo`: For receiving both InPage and banner ads.
   - `inpage`: For receiving only InPage ads.
   - `instream`: For receiving only InStream ads.
     
   If the response contains `json/html` or the `codeType` parameter isn't set, a banner ad is served.
  
- **sizes**: A banner size. A mandatory parameter for monetizers integrated with Prebid.js and some other monetizers (see the table with monetizer data in step 2.6 above).

   An array of arrays in which the first value is a width and the second value is a height.
 
   {% cut "For example" %}
 
   ```javascript
   sizes: [[ 728, 90 ]];
   ```
 
   {% endcut %}

- **bids**: Data on monetizers that are connected to the auction for this placement. It is an array of objects:
   - `bidder`: Monetizer key.
   - `params`: The object with `placement parameter`: `value` pairs, where:
       - `placement parameter`: Setting for a specific monetizer.
       - `meaning`: Set of parameters to get from the monetizer.
       
       The contents of the `params` object depend on the monetizer:
       
       - For Yandex Header Bidding monetizers: `Placement ID: value`.

         {% cut "Example of bids for the Between Digital monetizer" %}

         ```javascript
         {
          bidder: 'betweenDigital',
          params: {
            placementId: 8
          },
         }
         ```

         {% endcut %}

       - For monetizers integrated with Prebid.js, see the list of parameters in step 2.6 in the instructions above.

         {% cut "Example of bids for the AdRiver monetizer (Prebid)" %}
 
         ```javascript
         {
           bidder: 'pb_adriver',
           params: {
             'siteid': 216200
             'placementId': '55:test_placement'
           },
         }
         ```
 
         {% endcut %}
 
       - For monetizers working via Adfox HB, fill in the `'parameter': 'value'` pairs from the `params` object in the monetizer ad tag.

         {% cut "For example" %}
  
         ```javascript
         {
           bidder: 'adfox_example',
           params: {
             'p1': 'bxzlm',
             'p2': 'ekwz'
           },
         }
         ```
  
         {% endcut %}

       The `params` object can include an optional element, namely the `additional` object with additional request parameters determined by agreement with the monetizer.

       {% cut "Example with optional parameters of the params object" %}

      ```javascript 
      {
        bidder: 'betweenDigital',
        params: {
          placementId: '8',
          additional: { // Additional request parameters       pos: 123,
            ref: 'my-site/page'
          },
        },
      }
      ```

       {% endcut %}

       {% cut "The adUnit array with optional params elements" %}

      ```javascript 
      AdUnit 
      [
        {
          code: string; 
          sizes: Sizes; 
          bids: [
            {
              bidder: 'mytarget',
              params: {
                placementId: '320552',
                additional: { // Additional request parameters             pos: 123,
                  ref: 'my-site/page'
                },
              },
            }
          ];
        }
      ]                                    
      ```
      
      {% endcut %}

||
|| `timeout` | The timeout for a response from the monetizer's server. The recommended timeout is 500 ms. The maximum possible value is 3000 ms, but the main content of the site will load with a delay if this value is specified. ||
|| `trustedOwners` | Optional parameter. If you plan to send bids to other Adfox account requests via the **Adfox code forwarding [context]** template, specify the IDs of the accounts where the codes are forwarded from. ||
|#



{% endcut %}



## Other examples of scripts with header-bidding.js {#other-examples}


{% cut "Example of embedding scripts and placing ad placements" %}


```html
<head>       
  
  
  
  
</head>
<body>
  <div id="adfox_1"></div>
  
  <div id="adfox_2"></div>
  
  <div id="adfox_3"></div>
  
</body>
```


{% endcut %}

{% cut "Example of connecting InPage ads" %}


```html

        
        
        
<div id="slot" style="width: 640px; margin: 0 auto;"></div>
```

{% endcut %}

{% cut "Example of connecting Combo ads" %}


```html




```


{% endcut %}



## Demo pages {#demo-page}

Use the links below to view examples of banners where Header Bidding is used.

[InPage video](https://yandex.ru/project/yan/adfox-specs/header-bidding-examples/adfox-inpage-header-bidding)


<!-- source: en/_includes/feedback.md -->
## Contact support


<a href="en/form"> <!--ссылка, куда ведет кнопка. Если внутренняя ссылка, пишем без .md и .html --> 
  <span class="button">Send an email</span> <!--текст на кнопке--> 
</a>



<!-- source: en/_includes/styles/button.md -->

<!-- endsource: en/_includes/styles/button.md -->
<!-- endsource: en/_includes/feedback.md -->

[*combo]: Send banners and InPage videos at the same time.