Header bidding is the single most impactful upgrade a WordPress publisher can make to their ad monetization. It replaces the old sequential waterfall model (where Google gets first look at every impression) with a simultaneous auction where multiple demand partners compete in real time. The result is consistently 30-50% higher revenue on the same traffic.
But setting up header bidding can range from trivially easy to extremely complex, depending on the approach you choose. This guide covers three paths: the full manual Prebid.js setup (for technically advanced publishers who want total control), the Google Ad Manager integration path (for publishers already using GAM), and the managed platform approach (for everyone else who wants header bidding revenue without the technical overhead).
We recommend reading all three sections before choosing your path. Understanding the manual process helps you appreciate what managed platforms handle for you, and helps you make more informed decisions about your ad stack.
Understanding Header Bidding Architecture
Before diving into setup, it helps to understand the components of a header bidding system and how they interact.
The Components
- Header bidding wrapper (Prebid.js): JavaScript library that runs in the user's browser. It manages bid requests to multiple demand partners, collects their responses, and passes the winning bids to your ad server. Prebid.js is the industry standard open-source wrapper.
- Demand partners (SSPs/exchanges): Companies like Google Ad Exchange, Amazon TAM, Index Exchange, OpenX, PubMatic, and Sovrn that connect advertisers to your inventory. Each has a Prebid adapter that tells Prebid.js how to communicate with them.
- Ad server (Google Ad Manager): The decision engine. It receives the highest header bidding bid, compares it against its own demand (Google Ad Exchange), and selects the overall winner. GAM ensures that header bidding and Google demand compete fairly.
- Ad units: The slots on your page where ads appear. Each ad unit is defined with a size, position, and the demand partners that should bid on it.
The Flow
When a user loads your WordPress page, here is what happens in order:
- Step 1: Prebid.js loads and sends bid requests to all configured demand partners simultaneously
- Step 2: Demand partners respond with bids (or no-bids) within the timeout window (1.5-3 seconds)
- Step 3: Prebid.js collects all bids and passes the highest bid to Google Ad Manager via key-value targeting
- Step 4: GAM compares the header bidding winner against Google's own demand (Ad Exchange)
- Step 5: The overall highest bidder wins, and their creative renders in the ad slot
This entire process happens within 2-3 seconds, invisible to the user. For more background on how this compares to the older waterfall method, read our header bidding vs. waterfall guide.
Path 1: Manual Prebid.js Setup (Advanced)
This path gives you maximum control but requires significant technical expertise. Expect 40-80 hours for initial setup and ongoing maintenance effort. For a more detailed walkthrough, see our dedicated Prebid.js setup guide.
Step 1: Set Up Google Ad Manager
If you do not already have a GAM account, sign up at admanager.google.com. You need a GAM account even for header bidding because GAM serves as the ad server that makes the final selection between header bidding bids and Google demand.
In GAM, create ad units for each ad slot on your WordPress site. Typical units include:
- Top leaderboard (728x90 desktop, 320x50 mobile)
- In-content 1 (300x250)
- In-content 2 (300x250)
- Sidebar (300x250 or 300x600)
- Sticky footer (728x90 desktop, 320x50 mobile)
For each ad unit, you need to create line items that represent each possible bid price from header bidding partners. This is the most tedious part: you need line items for every price increment (typically $0.01 increments from $0.01 to $20.00, which is 2,000 line items per ad size). Tools like Prebid's line item manager can automate this creation, but it still requires careful configuration.
For the full GAM setup process, see our Google Ad Manager setup guide.
Step 2: Build Your Prebid.js Bundle
Go to prebid.org and use the download tool to build a custom Prebid.js bundle with only the bidder adapters you need. Including all adapters creates an unnecessarily large file. Select adapters for 6-10 demand partners relevant to your traffic.
Common bidder adapters for WordPress publishers:
- appnexus (Xandr/Microsoft)
- ix (Index Exchange)
- openx (OpenX)
- pubmatic (PubMatic)
- sovrn (Sovrn)
- criteo (Criteo)
- rubicon (Magnite)
- amazonTAM (Amazon Publisher Services)
You need an approved publisher account with each SSP before their adapter will work. Apply to each partner, get approved, and receive your publisher/seat IDs.
Step 3: Configure Prebid.js
Create your Prebid.js configuration file. This defines your ad units, which bidders compete for each unit, timeout settings, and price granularity. A simplified example configuration:
Prebid.js Configuration Overview
Ad Units: Define each slot with code, media types (banner sizes), and bidder configurations
Bidder Settings: Publisher IDs for each demand partner, bid adjustment multipliers
Auction Settings: Timeout (recommended: 1500-2500ms), price granularity (medium or dense), currency
GPT Integration: Key-value targeting to pass winning bids to Google Ad Manager
The configuration must be tested thoroughly. Incorrect bidder parameters, wrong ad unit codes, or mismatched key-values will cause bids to not register in GAM, which means header bidding partners win the auction but GAM does not know about it and serves Google demand at a lower price.
Step 4: Add Code to WordPress
Add the Prebid.js library and your configuration to your WordPress site's <head> section. You can do this via:
- Theme header.php: Edit your child theme's header.php to include the script tags before
</head> - WPCode plugin: Add the scripts via the Insert Headers and Footers functionality without editing theme files
- Custom plugin: Create a small WordPress plugin that enqueues the Prebid.js script. This survives theme changes.
Add the Google Publisher Tag (GPT) code and ad slot div elements to your page templates where ads should appear. For in-content placements, use an ad injection plugin to insert the ad divs between paragraphs automatically.
Step 5: Update ads.txt
Add ads.txt entries for every demand partner. Each SSP provides their required ads.txt lines. Upload the complete file to your WordPress root directory.
Step 6: Test and Launch
Before going live, use Prebid.js debugging tools (add ?pbjs_debug=true to your URL) to verify that all bidders are receiving requests and returning bids. Check the browser console for errors. Verify that bids are being correctly targeted in GAM by checking the key-value pairs in the ad request.
Common issues during testing:
- Bidders returning no bids: Usually wrong publisher IDs or account not yet approved
- Bids not rendering in GAM: Key-value mismatch or line item configuration error
- Slow page load: Too many bidders or timeout set too high
- Ads not showing on mobile: Responsive ad unit configuration missing mobile sizes
Path 2: Google Ad Manager with Prebid Server (Intermediate)
Prebid Server moves the bidding auction from the user's browser to a server. Instead of the browser making 8-10 simultaneous requests to different SSPs (which adds latency), a single request goes to the Prebid Server, which handles all bidder communication server-side and returns results to the browser.
Advantages over Client-Side
- Faster page loads: Only one request from the browser instead of many
- More bidders without latency penalty: Server-side can handle 15-20+ bidders without impacting user experience
- Better mobile performance: Mobile devices with slower connections benefit most from reduced request count
Disadvantages
- Lower match rates: Server-side bidding has limited access to user cookies and device data, which reduces bid accuracy and CPMs by 10-20% for some partners
- Hosting costs: You need to run a Prebid Server instance or use a hosted service
- More complex setup: Configuration involves both client-side wrapper code and server-side bidder adapters
The hybrid approach (running some bidders client-side and others server-side) is increasingly popular. High-priority bidders that benefit from cookie matching run client-side, while additional bidders run server-side for incremental demand without latency cost.
Path 3: The Easy Way with WeForAds (Recommended)
For the vast majority of WordPress publishers, a managed platform provides the best return on time invested. Here is the complete WeForAds setup process for WordPress:
Step 1: Create Your WeForAds Account (2 minutes)
Visit weforads.com/signup and create an account. Add your WordPress site URL. The platform generates a unique script tag for your site that contains all the header bidding logic and demand partner configurations.
Step 2: Add the Script Tag to WordPress (5 minutes)
Method A: Using WPCode plugin (no coding required)
- Install and activate the WPCode (Insert Headers and Footers) plugin from the WordPress plugin directory
- Go to Code Snippets > Header & Footer in your WordPress admin
- Paste the WeForAds script tag in the "Header" section
- Save changes
Method B: Editing theme files (requires FTP or file manager access)
- Open your child theme's header.php file (create a child theme if you do not have one to survive theme updates)
- Paste the script tag before the closing
</head>tag - Save and upload the file
Method C: Using a custom mini-plugin
Create a simple WordPress plugin file that adds the script to the header via the wp_head action hook. This method survives both theme changes and plugin deactivation, making it the most durable approach.
Step 3: Upload ads.txt (2 minutes)
Download the complete ads.txt file from your WeForAds dashboard. Upload it to your WordPress root directory (the same folder as wp-config.php) via FTP, file manager, or the ads.txt manager plugin. Verify it is accessible at yourdomain.com/ads.txt.
Step 4: Remove Old AdSense Code (3 minutes)
If you were running AdSense, remove the old ad code from your pages. This includes:
- Removing AdSense script tags from your header
- Removing ad unit div elements from your templates and widgets
- Deactivating any AdSense WordPress plugins
- Disabling Auto Ads in your AdSense dashboard
You do not need to close your AdSense account. WeForAds includes Google demand (through Ad Exchange) as one of many bidders in the auction. Google still competes for your impressions but now has to outbid other partners to win them.
Step 5: Verify and Monitor
After installation, visit your site and verify ads are loading. The WeForAds dashboard shows real-time data on impressions, revenue, eCPMs, and fill rates. Allow 7-14 days for full optimization as demand partners calibrate their bids for your specific traffic.
Total setup time: under 15 minutes, zero coding required.
Performance Optimization Tips
Regardless of which path you choose, these optimization practices maximize your header bidding revenue on WordPress.
Optimize Bid Timeout
The bid timeout determines how long the page waits for demand partners to respond. Too short (under 1 second) means partners do not have time to bid, reducing competition. Too long (over 3 seconds) means the user stares at a blank page waiting for ads.
Recommended settings: 1500ms for Tier 1 traffic (US/UK), 2000-2500ms for mixed traffic, 2500-3000ms if you have many server-side bidders. For more details, see our header bidding timeout optimization guide.
Implement Lazy Loading
Do not load all ad slots on initial page render. Ads below the fold should load only when the user scrolls within 300-500px of the ad position. This improves page load speed, reduces initial JavaScript execution, and improves ad viewability (because ads render just before the user sees them). See our lazy loading guide for implementation details.
Use Responsive Ad Units
Configure each ad slot to accept multiple sizes. An in-content slot that accepts both 300x250 and 336x280 will attract more bidders and higher prices than a slot locked to a single size. On desktop, allow 728x90 and 970x250 for leaderboard positions. Multi-size slots increase demand competition without adding more slots to the page.
Monitor Core Web Vitals
Header bidding adds JavaScript that affects Core Web Vitals, particularly Cumulative Layout Shift (CLS) and Largest Contentful Paint (LCP). Reserve space for ad slots using CSS min-height to prevent layout shift. Load ad scripts asynchronously. Test your Core Web Vitals score after installation using Google PageSpeed Insights.
A/B Test Configurations
Do not assume your initial setup is optimal. Test different numbers of ad slots, different placement positions, different floor prices, and different refresh intervals. Even small improvements compound significantly: a 5% eCPM increase on 500,000 monthly impressions at $3.00 eCPM means $75/month more revenue from a single test.
Common WordPress-Specific Issues
Plugin Conflicts
Some WordPress optimization plugins (caching, minification, lazy loading) can interfere with ad scripts. WP Rocket, W3 Total Cache, and Autoptimize may need exceptions for ad-related JavaScript. If ads are not loading after installing a new optimization plugin, check if it is minifying or deferring your ad scripts.
Theme Compatibility
WordPress themes vary widely in their HTML structure. Ad placement plugins that inject ads between paragraphs may not work correctly with all themes, especially page builder themes (Elementor, Divi, Beaver Builder) that generate non-standard markup. Test ad placements on your specific theme before going live.
CDN and Caching
If you use a CDN (Cloudflare, StackPath) or caching plugin, ensure that ad scripts are excluded from caching. Cached ad scripts may serve stale configurations or prevent dynamic bidding from occurring. The ads.txt file should also bypass any CDN caching to ensure crawlers always see the latest version.
Frequently Asked Questions
Do I need Google Ad Manager for header bidding on WordPress?
For a manual Prebid.js setup, yes. GAM acts as the decision layer comparing header bidding bids against Google's own demand. With a managed platform like WeForAds, you do not need to set up or manage GAM yourself. The platform handles the ad server integration.
How much does header bidding increase WordPress ad revenue?
Most WordPress publishers see 30-50% revenue increase when switching from AdSense to header bidding. The increase comes from auction competition: multiple demand partners bid simultaneously instead of Google getting first look. Finance and technology sites often see 50-80% gains. See our ad revenue benchmarks for specific numbers by niche.
Will header bidding slow down my WordPress site?
A well-implemented setup adds 200-500ms. A poorly implemented one can add 2-3 seconds. Key practices: async script loading, 1.5-3 second bid timeout, lazy loading for below-fold slots, and limiting bidders to 6-10. Managed platforms like WeForAds are pre-optimized for minimal performance impact.
Can I set up header bidding on WordPress without coding?
Yes, with a managed platform. WeForAds requires adding one script tag via a WordPress plugin like WPCode, which takes 5 minutes with zero coding. Manual Prebid.js setup requires JavaScript knowledge, GAM configuration, and ongoing maintenance.
How many header bidding partners should I use?
6-10 partners is optimal. The first 3-5 provide the biggest revenue lift (20-35%). Partners 6-8 add moderate gains (5-15%). Beyond 10, additional partners add less than 2% revenue while increasing latency. Focus on partners strong in your verticals and geographies.
Want Header Bidding on WordPress in 10 Minutes?
WeForAds handles the entire header bidding stack through a single tag. No GAM setup, no Prebid.js configuration, no ongoing maintenance. Just higher revenue.
Get Started Free
By