How to Set Up Prebid.js: A Publisher Implementation Guide
By Theaimart ADX ·
5 minute read · AI-assisted technical review
Implement a first Prebid.js auction with approved bidders, consent gating, GPT targeting, a bounded timeout and one initial request. Includes tested coordination source.
What a Prebid.js implementation requires
A Prebid.js tutorial needs more than a bidder array. You need approved demand accounts, a reviewed Prebid build, an ad server with compatible line items and creatives, authorized sellers, an eligibility/consent path and a way to handle no bids. Prebid does not supply advertising demand or guarantee revenue by itself.
This guide follows Prebid's getting-started documentation, its basic example and GPT loading controls, reviewed on 12 November 2026. The accompanying code is a teaching integration, with local queue/timeout fixtures, not a verified live campaign.
Step 1: define the inventory and commercial relationships
Start with one banner slot on a test property. Record its element ID, allowed sizes, device rules and the corresponding Google Ad Manager ad-unit path. Obtain real bidder parameters from approved accounts. Do not copy a demo placement ID into production.
Confirm who owns the existing ad stack. If a managed partner already runs auctions, coordinate with that partner before adding a wrapper. Define privacy responsibilities and the point at which the page is allowed to request ads. This example assumes the application supplies that decision; it does not implement a consent-management platform.
Step 2: build only what you need
Choose a current Prebid release and the required bidder and privacy modules. Review its release notes and the chosen adapters' documentation. Keep the artifact version and build configuration in the release record. Do not use an unpinned anonymous bundle merely because a tutorial links to it.
Load GPT through Google's documented source and your reviewed Prebid artifact asynchronously. Reserve a container matching the responsive placement design. Production CSP, deployment and caching must permit the actual scripts and creative paths; this article does not change the ADX website's own ad behavior.
Step 3: configure the ad server
Create the required price-priority line items, key-values and creatives following current Prebid instructions. Align price granularity, currency and creative behavior with the wrapper configuration. A bid response in developer tools is insufficient if no matching line item can serve it.
Use the correct ad-unit path and size mapping. Check that directly sold campaigns and other priorities still behave as intended. Ad-server setup is account-specific; no fictional account identifiers are presented as a working production configuration.
Step 4: coordinate one initial request
The companion source is integrated at examples/blog/prebid/publisher-auction.js. It exports startPublisherAuction(config). The application must invoke it only after its actual eligibility gate allows ads, with an approved adUnitPath, code, sizes and bids configuration. Load this teaching source alongside your own reviewed Prebid build and GPT, not as a new site-wide script on ADX.
The sequence is disable GPT initial loading, define/register the slot, request bids, set GPT targeting when available and refresh the explicit slot once. A separate fallback covers missing or delayed Prebid. The code uses a 1,200ms bidder window and a 1,800ms fallback only as teaching values; tune them using your own measured experience.
The following small executable fixture illustrates the single-request guard. The mock functions are deliberately labeled: they test coordination, not the behavior of GPT or a real bidder.
javascript ·
function once(start) {
let sent = false;
return function () {
if (sent) return;
sent = true;
start();
};
}
const events = [];
const finish = once(() => {
events.push('mock targeting');
events.push('mock refresh');
});
finish(); // Bids callback
finish(); // Fallback racing with that callback
console.log(events);Step 5: test timing and no-bid behavior
The complete companion source adds queued GPT and Prebid loading to the guard. Local fixtures exercise bids before GPT readiness, fallback before the bidder callback, Prebid missing and a late Prebid load after fallback. They verify one initial refresh and no auction started after the fallback decision. These checks do not contact advertising services.
Test a real account in the provider's approved test environment before live release. Inspect bidder responses, targeting keys, selected line items, creative rendering and reported impressions separately. Include blocked scripts, no bids, denied eligibility, wrong sizes and route navigation. Do not click live ads to test reporting.
A production integration also needs cleanup and refresh behavior for its actual page lifecycle. The teaching source deliberately permits only one initial auction and throws if started again. It does not implement SPA navigation, viewability-based refresh or multi-slot orchestration.
Step 6: verify authorization and privacy
Publish verified partner entries in ads.txt and check seller-account mappings. The ads.txt and sellers.json guide owns that setup. A correct authorization file cannot repair a broken bidder adapter or ad-server creative.
Test the consent/eligibility path before scripts or requests that require it. Include changes of choice and unavailable consent information according to the current provider instructions. Never treat the snippet's existence as privacy-compliance evidence.
Step 7: evaluate a controlled rollout
Track eligible opportunities, bids, timeouts, shown impressions, finalized net revenue and reader performance. Keep format and layout changes visible. A successful initial auction proves a technical path, not commercial superiority over a simpler setup.
Set a rollback procedure and record the exact build. The header-bidding versus waterfall guide helps decide whether the operational commitment is justified, and the RPM guide covers evaluation.
Theaimart ADX's availability disclosures do not establish a verified Prebid adapter or live bidder partnership. This tutorial does not invent one or enable ads on this website.
Frequently asked questions
Why disable initial load? To avoid sending the first GPT ad request before the intended targeting decision. Why a separate fallback? A missing wrapper must not leave the initial request waiting forever. Does a higher bid mean a paid impression? No; targeting, selection, rendering and reporting still have to succeed. Can I paste this into production? Complete the account-specific, privacy and lifecycle work first.