# Prebid.js

Source: https://docs.ezoic.com/docs/prebid-adapter/prebid-js/


There are two ways to add Ezoic to Prebid.js on your pages:

- **The `ezoicBidAdapter` module** (Prebid.js 11.39.0 or newer). This is the recommended route.
- **A hosted installer script** for Prebid.js 9.30 and newer, if you can't rebuild Prebid.js. See [Older Prebid.js builds](#older-prebidjs-builds-hosted-installer).

Complete the [onboarding steps](/docs/prebid-adapter/#before-you-start) first: unregistered domains get no bids.

## Add the module

Include `ezoicBidAdapter` in your Prebid.js build, either by ticking it on the [Prebid.js download page](https://docs.prebid.org/download.html) or when building from source:

~~~bash
gulp build --modules=ezoicBidAdapter,...your other modules
~~~

Then add `ezoic` to the `bids` of each ad unit you want Ezoic demand on:

~~~javascript
pbjs.addAdUnits([{
  code: 'div-leaderboard',
  mediaTypes: { banner: { sizes: [[728, 90], [970, 90]] } },
  bids: [
    { bidder: 'ezoic', params: {} },
    // ...your other bidders
  ]
}]);
~~~

`params: {}` is valid. The only parameter is optional:

| Name | Scope | Type | Description | Example |
|---|---|---|---|---|
| `placementId` | optional | string | Your own name or ID for the slot. Recorded for reporting; must be a non-empty string if set. | `'leaderboard-top'` |

### Floors

If you run the Prebid.js floors module, the adapter calls `getFloor()` for each impression and sends the result to Ezoic. No extra setup is needed.

### Video

- **Instream:** works with the standard Prebid.js video and ad server setup.
- **Outstream:** the adapter returns VAST and does not bundle a renderer. Supply a renderer on the ad unit (or use a Prebid Cache setup your player reads from). Prebid.js rejects outstream bids that have neither.

### User sync

Ezoic matches users through one iframe sync (`https://g.ezoic.net/ezoic/prebid/adapter/usersync-frame`). Matched users bid at noticeably higher rates. Prebid.js only allows image syncs by default, so allow iframes for `ezoic`:

~~~javascript
pbjs.setConfig({
  userSync: {
    filterSettings: {
      iframe: { bidders: ['ezoic'], filter: 'include' }
    }
  }
});
~~~

The sync honors TCF (vendor 347), GPP, and US Privacy signals.

## Older Prebid.js builds: hosted installer

If you're on Prebid.js 9.30 or newer but can't add a module to your build, load Ezoic's hosted installer. It registers the `ezoic` bidder with the Prebid.js instance already on your page. Load order doesn't matter.

~~~html
<script async src="https://cdn.example.com/your/prebid.js"></script>
<script async
  src="https://g.ezoic.net/ezoic/prebid/adapter.js"
  data-namespace="pbjs"
  data-autoincludeinauctions="false"></script>
~~~

| Attribute | Default | Purpose |
|---|---|---|
| `data-namespace` | `pbjs` | The global name of your Prebid.js instance, if you renamed it. Must be a single `window` property. |
| `data-autoincludeinauctions` | `false` | Set to `"true"` to add Ezoic to eligible banner ad units automatically instead of editing them. |

Then add `{ bidder: 'ezoic', params: {} }` to your ad units as above, or turn on auto-include. Auto-include only adds Ezoic to ad units that have banner sizes, are banner-only, already have at least one other bidder, and don't already list `ezoic`.

Notes:

- `https://www.ezojs.com/ezoic/prebid/adapter.js` serves the same file.
- Including it twice is safe. If your Prebid.js can't register bidders at runtime, it does nothing and your auctions run as before.
- If you haven't set an iframe sync policy, the installer runs the Ezoic user sync itself after the auction, honoring your `userSync` settings and consent. If you have set one, include `ezoic` in it as shown above.

## Check that it works

1. Open your page with `?ezoic_prebid_adapter_debug=1`.
2. In the Network tab, find the POST to `https://g.ezoic.net/ezoic/prebid/adapter`. It returns HTTP 200 with either bids or `{"nobid":true,"reason":"..."}`. `no_demand` is normal: the Ezoic auction ran and nothing beat the floor.
3. `pbjs.getBidResponses()` shows `ezoic` bids when Ezoic wins its own auction.
4. Winning creatives render through your normal ad server and `pbjs.renderAd` flow. Ezoic's markup is self-contained, including its impression tracking.

## Content Security Policy

If your site uses CSP, allow:

~~~text
script-src  https://g.ezoic.net    (installer only; or https://www.ezojs.com)
connect-src https://g.ezoic.net https://pbserver.ezoic.com
~~~

## Troubleshooting

| Symptom | Likely cause |
|---|---|
| No POST to `/ezoic/prebid/adapter` | No ad unit lists `ezoic` (and auto-include is off), the module isn't in your build, or `data-namespace` doesn't match your Prebid.js global. |
| `nobid` with `no_demand` on every request | Floors above available demand, ads.txt entries missing, or the domain isn't set up with demand yet. Contact Ezoic. |
| `nobid` with `context_error` that persists | Usually the domain isn't registered with Ezoic. |
| Outstream video bid rejected | No renderer on the ad unit. Add one or keep the slot banner-only. |
| CPMs lower than partner-reported gross | Ezoic bids are net of revenue share. |

When contacting Ezoic, include the page URL, `pbjs.version`, and the `/ezoic/prebid/adapter` request and response (with `?ezoic_prebid_adapter_debug=1`).

