> For the complete documentation index, see [llms.txt](https://adagio-io.gitbook.io/adagio-documentation/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://adagio-io.gitbook.io/adagio-documentation/prebid/prebid.js-getting-started/js-configuration-examples.md).

# JS Configuration Examples

<details>

<summary><strong>Simple adUnit configuration (<code>for banner, outstream, native</code>)</strong></summary>

```javascript
var adUnits = [{
  // Declare you adunit code here
  code: "div-gpt-ad-1542984663788-0",

  // Declare you mediatypes here
  mediaTypes: {

    // Mediatype: banner
    banner: {
      sizes: [
        [300, 250]
      ], // Review supported sizes here
    },

    // Mediatype: video (outstream)
    video: {
      context: 'outstream', // Required
      api: [2], // Required - Your video player must support the value '2' (we don't support value '7')
      playbackmethod: [6], // Required - Highly recommended
      // ...Please add any other relevant OpenRTB 2.6 video options.
    },

    // Mediatype: native
    native: {
      context: 1,
      plcmttype: 2,
    },
  },

  // Declare you Adagio parameters here
  bids: [{
    bidder: "adagio",
    params: {
      organizationId: "1000", // Required
      site: "my-site", // Required
      placement: "my-adg-placement", // Required
    },
  },],

  // Ortb2Imp - Params shared between all bidders
  ortb2Imp: {
    ext: {
      data: {
        divId: "div-gpt-ad-1460505748561-0", // Required
      },
    },
  },
},];

```

</details>

<details>

<summary><strong>Simple adUnit configuration (<code>for instream</code>)</strong></summary>

```javascript
var adUnits = [{
  // Declare you adunit code here
  code: "div-gpt-ad-1542984663788-0",

  // Declare you mediatypes here
  mediaTypes: {

    // Mediatype: video (instream): github.com/interactiveAdvertisingBureau/openrtb2.x/blob/main/2.6.md#objectvideo
    video: {
      // Required params
      context: 'instream',
      playerSize: [[640, 480]], // Any size you want to monetize.
      mimes: ['video/mp4', 'video/ogg', 'video/webm', 'application/javascript'], // Add these four mimes to optimise the performances. 
      api: [1, 2, 3, 4, 5], // API frameworks either supported by a placement. You must support at least one value.
      plcmt: 1, // We require value '1'. See https://docs.prebid.org/dev-docs/pb9-notes.html#video-ortb2-objects

      // Highly recommended params
      playbackmethod: [2], // Media playback methods.
      startdelay: 0, // Represents video start delay.
      protocols: [3, 6, 7, 8], // MediaCreativeSubtype represents subtypes of video ad creatives.
    },
  },

  // Declare you Adagio parameters here
  bids: [{
    bidder: "adagio",
    params: {
      organizationId: "1000", // Required
      site: "my-site", // Required
      placement: "my-adg-placement", // Required
    },
  },],

  // Ortb2Imp - Params shared between all bidders
  ortb2Imp: {
    ext: {
      data: {
        divId: "div-gpt-ad-1460505748561-0", // Required

      },
    },
  },
},];
```

</details>

<details>

<summary>Full Prebid configuration example</summary>

```html
<html>

<head>
  <script>
    window._iub = window._iub || {};
    _iub.csConfiguration = {
      cookiePolicyId: 417383,
      siteId: 1,
      logLevel: "error",
      lang: "en",
      enableTcf: true,
    };
  </script>
  <script src="//cdn.iubenda.com/cs/tcf/beta/stub.js"></script>
  <script async src="//cdn.iubenda.com/cs/beta/iubenda_cs.js"></script>
  <script async src="../../build/dev/prebid.js"></script>
  <script async src="//www.googletagservices.com/tag/js/gpt.js"></script>

  <script>
    var PREBID_TIMEOUT = 700;
    var FAILSAFE_TIMEOUT = 2500;

    var adUnits = [
      {
        // Adunit code and mediatypes parameters
        code: "div-gpt-ad-1460505748561-0",
        mediaTypes: {
          banner: {
            sizes: [
              [300, 250],
              [300, 600],
            ],
          },
        },

        // Bids - Declare you bidder parameters here
        bids: [
          {
            bidder: "adagio",
            params: {
              organizationId: "1000", // Required
              site: "my-site", // Required
              placement: "my-adg-placement", // Required
            },
          },
        ],

        // Ortb2Imp - Params shared between all bidders
        ortb2Imp: {
          ext: {
            data: {
              divId: "div-gpt-ad-1460505748561-0", // Required
            },
          },
        },
      },
    ];

    var pbjs = pbjs || {};
    pbjs.que = pbjs.que || [];
  </script>

  <script>
    var googletag = googletag || {};
    googletag.cmd = googletag.cmd || [];
    googletag.cmd.push(function () {
      googletag.pubads().disableInitialLoad();
    });

    pbjs.que.push(function () {
      pbjs.addAdUnits(adUnits);
      pbjs.setConfig({
        realTimeData: {
          dataProviders: [
            {
              name: "adagio",
              params: {
                organizationId: "1000", // Required
                site: "my-site",        // Required
              },
            },
          ],
        },
        ortb2: {
          site: {
            ext: {
              data: {
                pagetype: "article", // Recommended
                category: "economy", // Optional    
              }
            }
          }
        },
        userSync: {
          filterSettings: {
            iframe: {
              bidders: ['adagio'],
              filter: 'include'
            }
          }
        },
      });

      pbjs.enableAnalytics([{
        provider: 'adagio'
      }]);

      pbjs.requestBids({
        bidsBackHandler: sendAdserverRequest,
        timeout: PREBID_TIMEOUT,
      });
    });

    function sendAdserverRequest() {
      if (pbjs.adserverRequestSent) {
        console.log('early out');
        return;
      }
      pbjs.adserverRequestSent = true;
      googletag.cmd.push(function () {
        pbjs.que.push(function () {
          pbjs.setTargetingForGPTAsync();
          googletag.pubads().refresh();
        });
      });
    }

    setTimeout(function () {
      sendAdserverRequest();
      console.log("timeout in main pbjs fired");
      pbjs.adserverRequestSent = false;
    }, FAILSAFE_TIMEOUT);
  </script>
  <script>
    googletag.cmd.push(function () {
      googletag
        .defineSlot(
          "/19968336/header-bid-tag-0",
          [
            [300, 250],
            [300, 600],
          ],
          "div-gpt-ad-1460505748561-0" // !!! This div id is an example, you should refer to id in your html code
        )
        .addService(googletag.pubads());

      googletag.pubads().enableSingleRequest();
      googletag.enableServices();
    });
  </script>
</head>

<body>
  <h2>Prebid.js Test</h2>
  <h5>Div-1</h5>
  <div id="div-gpt-ad-1460505748561-0">
    <script type="text/javascript">
      googletag.cmd.push(function () {
        googletag.display("div-gpt-ad-1460505748561-0"); // !!! This div id is an example, you should refer to id in your html code
      });
    </script>
  </div>
</body>

</html>
```

</details>


---

# 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://adagio-io.gitbook.io/adagio-documentation/prebid/prebid.js-getting-started/js-configuration-examples.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.
