What is Header Bidding? Its Implementation, Architecture and more…

Introduction

Header bidding is a revolutionary programmatic advertising technique that has transformed how ad inventory is sold online. Unlike traditional methods, where publishers would offer inventory to a single ad exchange at a time, header bidding allows multiple demand sources to bid simultaneously, leading to higher competition and better revenue for publishers.

How Header Bidding Works

Header bidding introduces an efficient way to handle ad auctions by enabling a simultaneous bid from multiple demand sources. Traditionally, publishers used a waterfall model where inventory was offered to one demand source at a time, with each source having a set priority. This method relied on historical bidding because it prioritized the previous highest bidders which often led to revenue loss, as only the highest priority bidder was able to compete for the ad impression at any given moment even if lower priority bidders provided a better bid.

Header bidding changes this by allowing multiple demand sources to bid on the same impression at the same time. Here’s how it works:

      1. Ad Request: When a user visits a webpage, the header bidding script in the page’s <head> section triggers an ad request to various demand sources, including supply-side platforms (SSPs) and demand-side platforms (DSPs).
      2. Bid Collection: Each demand source responds with their bid price and ad creative. These responses are collected and compared in real time.
      3. Auction and Decision: The highest bid is selected, and the winning bid’s ad is then served to the user. The ad server is informed of the winning bid and serves the corresponding ad creative.

        By allowing bids from multiple sources simultaneously, header bidding reduces the latency associated with sequential bidding and ensures that each impression is sold at the highest possible price.

        Role of SSPs (Supply-Side Platforms) and DSPs (Demand-Side Platforms)

        Supply-Side Platforms (SSPs) and Demand-Side Platforms (DSPs) play crucial roles in the header bidding ecosystem.

            • SSPs: These platforms are used by publishers to manage and sell their ad inventory. SSPs help in maximizing ad revenue by connecting publishers with multiple demand sources. In the context of header bidding, SSPs are responsible for gathering and forwarding bid requests from the publisher’s site to various DSPs.

            • DSPs: These platforms are utilized by advertisers to manage their ad campaigns and bid on inventory. DSPs process bid requests from SSPs and provide bids based on their targeting criteria and bid strategies. In header bidding, DSPs respond to bid requests with their offers, which are then used to determine the highest bid for each impression.

          Header Bidding

          Introduction to Real-Time Bidding (RTB)

          Real-time bidding (RTB) is a key component of header bidding. It is a protocol that allows advertisers to bid on ad impressions in real time, with each impression being auctioned off within milliseconds. RTB operates through an open auction where multiple advertisers can place bids, and the highest bidder wins the opportunity to display their ad.

          In header bidding, RTB facilitates the competitive bidding process by providing a standardized way for demand sources to submit their bids and for publishers to evaluate them. The RTB protocol ensures that the bidding process is fast and efficient, enabling publishers to maximize their revenue and advertisers to reach their target audiences effectively.

          Key Components of Header Bidding

          Header bidding involves several key components that work together to provide real-time ad auctions that maximize revenue for publishers. Let’s take a look at these essential components to better understand how header bidding operates and how we can optimize its implementation. Here’s a breakdown of the key components:

          1. Header Bidding Wrappers

          Header bidding wrappers are JavaScript libraries or scripts that manage the header bidding process. They serve as an intermediary between the publisher’s website and various demand sources. Wrappers streamline the integration of multiple demand partners by providing a unified API for communicating with these partners.

          Popular Header Bidding Wrappers in the Market :

              • Prebid.js: One of the most widely used open-source header bidding wrappers. Prebid.js offers extensive support for various ad formats and integrations, providing a robust solution for managing header bidding.

              • Amazon Transparent Ad Marketplace (TAM): Amazon’s solution for header bidding, designed to optimize ad performance and streamline integration with Amazon’s ad network.

            These wrappers make essential features such as auction management, bid collection, and ad creative injection, easier to implement making them a crucial part of any header bidding setup.

            2. Ad Exchanges and Networks

            Ad exchanges and networks are platforms where advertisers and publishers transact in real-time. In a header bidding setup, these exchanges and networks receive bid requests from the header bidding wrapper and respond with bids for the ad impression.

                • Ad Exchanges: Platforms that facilitate the buying and selling of ad inventory in real-time. Examples include Google Ad Exchange and AppNexus. Ad exchanges connect with SSPs and DSPs to aggregate demand and provide competitive bids.

                • Ad Networks: Networks that aggregate ad inventory from multiple publishers and sell it to advertisers. Ad networks may also participate in header bidding by submitting bids through SSPs or directly to the wrapper.

              In header bidding, ad exchanges and networks contribute to the auction process by providing bids based on their advertisers’ campaigns and targeting criteria.

              3. JavaScript Implementation

              Importance of JavaScript in Header Bidding Setup JavaScript is central to header bidding because it enables the execution of the bidding logic directly within the user’s browser. The header bidding script, written in JavaScript, is placed in the <head> section of the publisher’s webpage, allowing it to execute before the ad server is called.

              Key Functions of JavaScript in Header Bidding

                  • Triggering Bids: JavaScript code initiates bid requests to various demand sources as soon as the page loads.

                  • Handling Responses: JavaScript collects and processes bid responses from different demand sources, comparing them to determine the highest bid.

                  • Injecting Ads: Once a winning bid is selected, JavaScript injects the ad creative into the webpage, ensuring that the ad is displayed to the user.

                The efficiency and effectiveness of header bidding largely depend on the quality of the JavaScript implementation, which must handle multiple asynchronous operations and ensure minimal impact on page load times.

                Behind-the-Scenes: How Header Bidding Requests Work

                To fully understand the complexities of header bidding, it’s important to go through the behind-the-scenes mechanics of how header bidding requests are generated, processed, and utilized. This section takes a deep dive into the implementation of header bidding requests, exploring the roles of HTTP requests, the pre-bid and post-bid phases, and the utilization of user data in the bidding process.

                How HTTP Requests are Generated and Processed

                At the core of header bidding are HTTP requests sent with messages from the publisher’s website to demand sources (SSPs, DSPs, and ad exchanges) to request bids for ad impressions. Here’s how these requests are handled:

                    • Initiation: When a user visits a webpage, the header bidding script (JavaScript) runs in the browser. This script sends HTTP requests to various demand sources to request bids for the ad space.

                    • Request Format: These HTTP requests are typically formatted in JSON or XML and include parameters such as ad unit size, placement ID, and other targeting criteria.

                    • Processing: The demand sources receive these requests, process them to determine their willingness to bid, and send back bid responses. Each response includes details like the bid amount, creative type, and advertiser information.

                  Pre-bid and Post-Bid Phases

                  Header bidding involves two distinct phases: the pre-bid phase and the post-bid phase. Understanding the differences between these phases is crucial for optimizing the bidding process.

                  Pre-Bid Phase:

                      • Bid Requests: During the pre-bid phase, the header bidding script sends bid requests to multiple demand sources before the ad server is called.

                      • Bid Collection: Demand sources respond with bids, which are collected and evaluated by the header bidding wrapper.

                      • Auction: The wrapper conducts an auction among the collected bids to determine the highest bid for the impression.

                    Post-Bid Phase:

                        • Ad Server Call: After the auction, the header bidding script sends the winning bid information to the ad server.

                        • Ad Serving: The ad server integrates the winning bid with its own ad-serving logic to deliver the ad to the user. The ad server may also include additional data or serve ads based on other criteria.

                      The pre-bid phase is critical for maximizing competition and revenue by soliciting bids before interacting with the ad server. The post-bid phase ensures that the winning bid is integrated into the final ad serving decision.

                      The Impact of User Data on Bidding Decisions

                      User data plays a major role in header bidding by influencing bid decisions and ad targeting. Here’s how user data is utilized:

                          • Targeting and Personalization: Demand sources use user data to tailor their bids based on user demographics, interests, and browsing behavior. For instance, a demand source might increase its bid for users who have shown interest in specific products or services.

                          • Data Collection: The header bidding script can collect user data through cookies, tracking pixels, and other mechanisms. This data is included in bid requests to provide demand sources with relevant information for making bidding decisions.

                          • Privacy Considerations: It’s important to handle user data responsibly, complying with privacy regulations such as GDPR and CCPA. User consent and data anonymization practices are essential to protect user privacy while still enabling effective ad targeting.

                        Tools to Check Behind the Scenes of Header Bidding

                        To effectively monitor and analyze the header bidding process, several tools can be employed to inspect network activity, debug issues, and optimize performance. Here are some of the most useful tools for checking behind the scenes of header bidding:

                        1. Browser Developer Tools

                        Utilizing Chrome DevTools to Monitor Network Activity

                        Browser developer tools, particularly Chrome DevTools, are essential for inspecting and debugging header bidding processes. Here’s how you can leverage Chrome DevTools:

                            • Network Tab: Use the Network tab to monitor all HTTP requests and responses generated during header bidding. This includes bid requests sent to demand sources and bid responses received. You can view request headers, response headers, payloads, and timings to analyze how different components interact.
                                  • Steps:
                                        1. Open Chrome DevTools (Right-click on the page → Inspect or press Ctrl+Shift+I).
                                        2. Navigate to the Network tab.
                                        3. Reload the page to capture network activity.
                                        4. Filter by “XHR” to focus on AJAX requests or search for specific request URLs related to header bidding.

                                      • Console Tab: The Console tab can be used to log JavaScript errors, warnings, and custom logs from the header bidding script. This is useful for debugging issues with bid requests, responses, and integration.
                                            • Steps:
                                                  1. Open the Console tab in Chrome DevTools.
                                                  2. Look for any error messages or warnings related to header bidding.

                                            • Performance Tab: Analyze the performance of header bidding operations, including timing for bid requests and responses, to identify potential bottlenecks or delays.
                                                  • Steps:
                                                        1. Go to the Performance tab in Chrome DevTools.
                                                        2. Record the performance while interacting with the page to capture network and scripting activity.

                                                2. Requestly

                                                How Requestly Can Be Used to Inspect Header Bidding Processes

                                                Requestly is a powerful tool for modifying and monitoring HTTP requests and responses. It can be particularly useful for inspecting header bidding processes:

                                                    • Turning Debug Mode On for Prebid.js : Debug mode in Prebid.js is essential for troubleshooting and optimizing ad delivery. To enable debug mode, you can set the pbjs_debug parameter to true in the query string or include the debug: true property in the Prebid.js configuration. This will allow you to see detailed logs and errors in the browser’s console, helping to identify issues with bid requests, responses, and auction processes.
                                                    • Loading Local Prebid.js on Production : Testing a locally modified version of Prebid.js on a production environment can be done using Requestly or similar tools. You can create a rule to intercept the request for the production Prebid.js file and redirect it to your local or a custom version hosted on a development server. This allows you to test changes without impacting the live environment for other users. Ensure to carefully monitor and validate the functionality as running local code in production can lead to unexpected behaviors if not properly managed.
                                                    • Redirecting Bids to a Mock Server : For testing purposes, redirecting bids to a mock server can be beneficial. This setup allows you to simulate various bidding scenarios and evaluate how your ad stack handles different responses. You can use Requestly to create a redirect rule that changes the bid request URL to point to a mock server. The mock server can return predefined bid responses, helping you to test and debug without involving real demand partners.

                                                  3. Other Monitoring Tools

                                                  Introduction to Tools like Fiddler and Charles Proxy

                                                  In addition to browser developer tools and Requestly, there are other specialized tools for monitoring and debugging HTTP traffic:

                                                      • Fiddler: Fiddler is a web debugging proxy that captures and inspects HTTP and HTTPS traffic. It provides detailed information about request and response headers, payloads, and timings.
                                                            • Features:
                                                                  • Traffic Inspection: Monitor all HTTP/HTTPS traffic, including bid requests and responses.

                                                                  • Breakpoints: Set breakpoints to intercept and modify requests and responses in real-time.

                                                                  • Performance Analysis: Analyze timing and performance data to identify latency issues.

                                                          • Charles Proxy: Charles Proxy is another powerful tool for monitoring and debugging HTTP and HTTPS traffic. It offers similar features to Fiddler, including request and response inspection and performance analysis.
                                                                • Features:
                                                                      • Request and Response Inspection: View and modify requests and responses to debug header bidding issues.

                                                                      • Bandwidth Throttling: Simulate different network conditions to test how header bidding performs under various scenarios.

                                                                      • Session Recording: Record and replay sessions to analyze historical data and diagnose issues.

                                                            Header Bidding Architectures

                                                            Over the years Header bidding has evolved to be an essential mechanism in programmatic advertising, allowing publishers to maximize revenue by simultaneously comparing bids from multiple demand sources. The architecture of header bidding can significantly impact its performance, efficiency, and implementation complexity. Let’s take a look at various header bidding architectures, comparing client-side and server-side approaches, exploring hybrid models, and discussing latency optimization.

                                                            Client-Side vs. Server-Side Header Bidding

                                                            Client-Side Header Bidding

                                                            In client-side header bidding, the entire bidding process is managed by the user’s browser. When a user visits a webpage, a piece of JavaScript (usually called a header bidding wrapper) is executed. This script sends bid requests to multiple demand partners (SSPs, DSPs) directly from the user’s browser. The bids are collected, and the highest bid is sent to the ad server for the final ad selection.

                                                            Advantages:

                                                                • Transparency: Publishers have greater visibility into the bidding process, as they can easily monitor the bids received and the demand partners participating.

                                                                • Control: Publishers can fine-tune the header bidding process, adjusting parameters like bid timeouts, bidder prioritization, and bid floors directly in the browser.

                                                              Disadvantages:

                                                                  • Latency: Since the bidding process occurs in the user’s browser, it can introduce latency, leading to slower page load times, especially on slower devices or networks.

                                                                  • Scalability: Managing multiple bid requests in the browser can become cumbersome as the number of demand partners increases.

                                                                Server-Side Header Bidding

                                                                Server-side header bidding, also known as server-to-server (S2S) bidding, offloads the bidding process to an external server. When a user visits a webpage, the browser makes a single request to the header bidding server, which then sends bid requests to multiple demand partners. The server collects all the bids and sends the highest bid back to the browser for ad serving.

                                                                Advantages:

                                                                    • Reduced Latency: Since the bidding process occurs on a server rather than in the user’s browser, it reduces latency and improves page load times.

                                                                    • Scalability: Server-side architecture can handle a larger number of demand partners without overwhelming the user’s browser.

                                                                  Disadvantages:

                                                                      • Transparency: Publishers have less visibility into the bidding process since it occurs on an external server. They may not have direct access to detailed bid data.

                                                                      • Data Privacy: User data, such as IP addresses and cookies, must be sent to the external server, raising privacy concerns and potential compliance issues.

                                                                    AspectClient-Side Header BiddingServer-Side Header Bidding
                                                                    LatencyHigher latency due to multiple bid requests from the browser.Lower latency as requests are processed on a server.
                                                                    TransparencyHigh transparency; publishers can easily monitor bids.Lower transparency; publishers have less visibility into bid data.
                                                                    ControlHigh control; publishers can adjust parameters in the browser.Limited control; most processes are managed server-side.
                                                                    ScalabilityLimited scalability; the browser can be overwhelmed by too many bidders.High scalability; can handle more bidders without affecting browser performance.
                                                                    PrivacyUser data stays within the browser; better for user privacy.User data is sent to an external server, raising potential privacy concerns.
                                                                    Implementation ComplexityEasier to implement but requires careful management of JavaScript in the browser.More complex to implement, involving integration with external servers.
                                                                    Page Load ImpactPotentially slows down page load times, especially on slower networks or devices.Minimal impact on page load times since bidding occurs off-site.
                                                                    Bidder ReachLimited by browser capabilities and network conditions.Can reach more bidders efficiently due to server-side processing power.
                                                                    DebuggingEasier to debug directly in the browser.Harder to debug; requires access to server logs and more sophisticated tools.
                                                                    CostGenerally lower cost, as it doesn’t require additional server resources.Higher cost due to the need for server infrastructure.
                                                                    Differences between client-side and server-side header bidding

                                                                    Bidder Integration

                                                                    Now let us see how we can integrate new demand sources, such as Supply-Side Platforms (SSPs) or Ad Exchanges, to add a new bidder you first have to configure the necessary APIs to ensure that these sources can participate in the real-time bidding process effectively. Proper bidder integration ensures that the right bidders can access the auction, submit bids, and ultimately, deliver ads that meet the publisher’s criteria.

                                                                    Example Code Snippet for Prebid.js Bidder Integration

                                                                    Below is a basic example of how to integrate a new bidder in Prebid.js, one of the most popular open-source header bidding wrappers. This example shows how to configure a bidder and add it to the auction process.

                                                                    				
                                                                    					// Define ad units
                                                                    var adUnits = [
                                                                        {
                                                                            code: 'ABC-DEF-GHI-143060212613151-9', // Ad unit code
                                                                            mediaTypes: {
                                                                                banner: {
                                                                                    sizes: [[300, 250], [300, 600]] // Ad unit sizes
                                                                                }
                                                                            },
                                                                            bids: [
                                                                                {
                                                                                    bidder: 'rubicon', // Bidder code
                                                                                    params: {
                                                                                        accountId: '12345', // Rubicon account ID
                                                                                        siteId: '10001',    // Site ID
                                                                                        zoneId: '12356'     // Zone ID
                                                                                    }
                                                                                },
                                                                                {
                                                                                    bidder: 'appnexus', // Another bidder
                                                                                    params: {
                                                                                        placementId: '84729', // Placement ID for AppNexus
                                                                                        keywords: ['sports', 'news'] // Optional targeting keywords
                                                                                    }
                                                                                }
                                                                            ]
                                                                        }
                                                                    ];
                                                                    
                                                                    // Initialize Prebid.js and set up bidders
                                                                    pbjs.que.push(function() {
                                                                        pbjs.addAdUnits(adUnits); // Add ad units to Prebid.js
                                                                        pbjs.requestBids({
                                                                            bidsBackHandler: function(bidResponses) {
                                                                                // Callback function when bids are returned
                                                                                pbjs.setTargetingForGPTAsync(); // Set targeting for Google Publisher Tags
                                                                                googletag.pubads().refresh(); // Refresh the ad slots
                                                                            }
                                                                        });
                                                                    });
                                                                    
                                                                    // Define Google Publisher Tag (GPT) slots
                                                                    googletag.cmd.push(function() {
                                                                        googletag.defineSlot('/37292/sports', [300, 250], 'ABC-DEF-GHI-143060212613151-9').addService(googletag.pubads());
                                                                        googletag.enableServices();
                                                                    });
                                                                    
                                                                    				
                                                                    			

                                                                    In this example:

                                                                    • AdUnits: Defines the ad unit on the page, including its code, sizes, and associated bidders.
                                                                    • Bids: Lists the bidders (e.g., Rubicon and AppNexus) and their specific parameters, such as account IDs and placement IDs.
                                                                    • pbjs.addAdUnits: Adds the defined ad units to the Prebid.js instance.
                                                                    • pbjs.requestBids: Requests bids from the configured bidders, handling the returned bids and setting the targeting for the ad server.

                                                                    This setup ensures that the specified bidders can participate in the auction, with their bids being considered when the ad is served.

                                                                    Handling Bidder APIs

                                                                    Different bidders may have varying API requirements and response formats. It’s crucial to handle these variations correctly to ensure compatibility with the header bidding wrapper.

                                                                      • Bidder Code: Each bidder typically has a unique code that identifies it within the header bidding ecosystem. This code must be used consistently throughout the integration.
                                                                      • API Authentication: Some bidders require authentication, which might involve sending API keys or tokens with each bid request. Ensure that these credentials are handled securely.
                                                                      • Bid Request Parameters: Bid requests must include the correct parameters expected by the bidder, such as ad unit sizes, placement IDs, and user data. These parameters must be correctly mapped and sent in the proper format.
                                                                      • Response Handling: The bid response from the SSP or Ad Exchange must be parsed and validated before being passed on to the ad server. This involves checking for errors, validating the bid price, and ensuring that the creative meets the publisher’s requirements.

                                                                    Performance Optimization

                                                                    Even after implementing header bidding to your site, you should always look at various ways to optimize it for the best performance lets take a look at some techniques used to optimize your header bidding setup 

                                                                    Latency Reduction Techniques

                                                                    Latency is the worst enemy for performance as delays in the bidding process can lead to lost revenue and poor user experiences. Let’s see how you can reduce latency for the best-performing bidding setup.
                                                                    • Content Delivery Networks (CDNs): Utilize CDNs to distribute your bidding scripts across multiple geographic locations. This reduces the time it takes for users to download the scripts, especially for global audiences.
                                                                    • Edge Computing: For server-side bidding, you can consider edge computing to process bid requests closer to the user’s location. By performing computations at the edge of the network, you can significantly reduce latency and improve response times.
                                                                    • Async Bid Requests: Ensure that bid requests are sent asynchronously to avoid blocking the page load process. This allows the page to continue loading while waiting for bid responses.
                                                                    • Code Minification: Minify JavaScript files to reduce their size, speeding up download times and execution.
                                                                    • Lazy Loading: Implement lazy loading for non-essential scripts to prioritize the loading of critical components.
                                                                    • Performance Profiling: Use tools like Chrome DevTools to profile your code and identify performance bottlenecks. Regularly review and optimize the execution time of your bidding scripts.

                                                                    Conclusion

                                                                    Header bidding has revolutionized the way digital advertising operates, offering publishers more control and advertisers better access to premium inventory. By diving into the technical aspects, understanding the architectures, and optimizing performance, you can unlock the full potential of this powerful tool. With the right tools, strategies, and continuous monitoring, header bidding can significantly enhance revenue and ad delivery efficiency. As the digital advertising landscape continues to evolve, staying informed and adaptive is key to success in this dynamic ecosystem.

                                                                    Frequently Asked Questions (FAQs)

                                                                    1. What is the difference between header bidding and waterfall bidding?

                                                                    Header bidding and waterfall bidding are both methods for serving ads, but they operate differently.

                                                                    • Header Bidding: It allows multiple demand sources (SSPs and DSPs) to bid simultaneously in a real-time auction before the ad server makes its decision. This ensures that the highest bid across all sources wins, potentially increasing ad revenue.
                                                                    • Waterfall Bidding: In contrast, waterfall bidding follows a sequential process where each demand source is given an opportunity to fill the ad slot one after the other. The first demand source that meets the price floor serves the ad, which may result in lower bids being accepted, leaving potential revenue on the table.

                                                                    2. How does header bidding impact page load times?

                                                                    Header bidding can impact page load times because it requires the browser to send and receive multiple bid requests and responses before the ad server makes a final decision. If not optimized properly, this can introduce latency and slow down the page. However, techniques like asynchronous loading, server-side header bidding, and optimized JavaScript can minimize the impact on load times.

                                                                    3. Can header bidding be used with all ad networks?

                                                                    Not all ad networks support header bidding. Header bidding requires networks to participate in a real-time auction, which not all ad networks are equipped to do. However, most major SSPs and DSPs support header bidding, and many ad networks are adapting to accommodate this technology as it becomes more prevalent in the industry.

                                                                    4. What are some common issues with header bidding implementation?

                                                                    Common issues with header bidding implementation include:

                                                                    • Latency: Poorly optimized header bidding can lead to increased latency and slow page load times.
                                                                    • Integration Complexity: Integrating multiple bidders and managing their responses can be complex, requiring careful configuration and testing.
                                                                    • Bidder Conflicts: Different bidders might use conflicting JavaScript or might not play well together, leading to issues in bid responses or ad delivery.
                                                                    • Ad Quality and Security: Without proper controls, there’s a risk of serving low-quality or malicious ads through certain bidders.

                                                                      Share this article:

                                                                      Subscribe to our weekly newsletter !

                                                                      Join 10k developers and QAs to get weekly updates with Requestly's newsletter.​

                                                                      This article was written by:

                                                                      Picture of Dinesh Thakur

                                                                      Dinesh Thakur

                                                                      Dinesh Thakur, a fascinated by technology since childhood, has mastered programming through dedication. Whether working solo or in a team, he thrives on challenges, crafting innovative solutions.

                                                                      Join 10k developers and get weekly updates with Requestly's newsletter.

                                                                      Contents