Prebid.js + Google Ad Manager setup guide

A practical, end-to-end walkthrough of integrating Prebid.js header bidding with Google Ad Manager (GAM): build the wrapper, push price-bucket line items, wire GPT, add lazy loading, and verify the auction with a live debug console. This is the same flow BuildPrebid automates inside the app.

Why integrate Prebid with GAM?

Prebid.js runs a client-side header bidding auction across multiple SSPs (PubMatic, Xandr, Magnite, Index Exchange, OpenX, and more). Google Ad Manager then picks the winning bid using hb_pb key-value targeting on price-bucket line items. The result: real competition for every impression, higher CPMs, and full control inside GAM's reporting and forecasting.

The 6 steps

  1. 1

    Install Prebid.js with the bidders you work with

    Build a Prebid.js wrapper that includes only the bidder adapters you use (PubMatic, AppNexus / Xandr, Magnite / Rubicon, Index Exchange, OpenX, Smart / Equativ, etc.) plus the consentManagement, currency and price-floors modules you need. Smaller builds load faster and reduce auction latency.

  2. 2

    Define your ad units and bidder params

    For each GAM ad slot (e.g. /1234/homepage_top), declare a Prebid ad unit with its sizes (300x250, 728x90, 970x250…) and the bidder params each SSP requires (siteId, placementId, adSlot, tagId). BuildPrebid ships presets and validates required fields.

  3. 3

    Create Prebid price-bucket line items in Google Ad Manager

    In GAM, create one order per price bucket (e.g. 0.10 → 20.00 in $0.10 steps using the 'dense' granularity). Each line item targets the Prebid key-value hb_pb=<bucket> and serves a 1x1 universal Prebid creative that calls pbjs.renderAd(). BuildPrebid pushes all of this in one click — no spreadsheets.

  4. 4

    Wire Prebid into GPT with requestBids → setTargetingForGPTAsync

    On every ad request, call pbjs.requestBids() with a bidsBackHandler that runs pbjs.setTargetingForGPTAsync() and then googletag.pubads().refresh(). Add a global failsafe timeout (typically 1000–1500ms) so a slow bidder never blocks the ad call.

  5. 5

    Add lazy loading, viewability refresh and consent

    Use IntersectionObserver to lazy-load ad slots near the viewport, refresh slots only when Active View reports them viewable, and gate the auction on a TCF / USP / GPP CMP signal. BuildPrebid's GAM ad code generator emits all of this for you.

  6. 6

    Verify with the BuildPrebid debug console

    Open the live preview and inspect bid responses, win prices, timeouts, GAM line item IDs, creative IDs, Active View status and refresh events. Confirm hb_pb is being set on the slot and that the winning bid actually rendered.

What BuildPrebid automates for you

  • Generates the Prebid.js wrapper with only the bidder adapters you need
  • Pushes Prebid orders, line items, creatives and hb_pb targeting into GAM via the SOAP API
  • Emits clean GPT ad tags with size mapping, lazy load, viewability refresh and CMP
  • Live Prebid + GAM debug console: bid responses, timeouts, line item IDs, Active View
  • WordPress plugin for category, tag, post ID and contextual keyword targeting

Frequently asked questions

How long does it take to push Prebid line items into GAM?
With BuildPrebid, generating and pushing a complete Prebid price-bucket order (200+ line items, hb_pb targeting, creatives) takes about a minute. Manual trafficking via spreadsheets typically takes hours per order.
What price-bucket granularity should I use?
For most publishers the 'dense' granularity ($0.01 steps up to $3, $0.05 up to $8, $0.50 up to $20) captures the most revenue without exploding line item counts. Use 'custom' if your floors and demand profile warrant it.
Do I need a CMP to run Prebid in the EU/UK?
Yes. Bidders require a valid TCF v2 consent string. Enable BuildPrebid's CMP module (Google Funding Choices, Didomi, Sourcepoint, or custom) so the auction waits for tcloaded before requesting bids.

Skip the manual work

Request invite-only access to BuildPrebid and get a complete Prebid + GAM setup in minutes.