reduceBidRequest
The reduceBidRequest hook allows you to modify or filter bid requests before they are sent to bidders through Prebid.js. This is useful for customizing bid parameters, adding targeting data, or conditionally skipping certain bid requests.
Example
Section titled “Example”window.htag = window.htag || {};window.htag.reduceBidRequest = function (bidRequest, config) { // Add custom targeting parameters bidRequest.params = { ...bidRequest.params, customParam: 'value', siteId: getSiteId(), };
// Skip bid request for mobile devices on specific placements if (isMobile() && config.elementId === 'sidebar-ad') { return null; }
return bidRequest;};Parameters
Section titled “Parameters”- bidRequest (object): The original bid request object that will be sent to the bidder
- Contains bidder-specific parameters and targeting information
- Structure varies by bidder but follows Prebid.js conventions
- config (object): The placement configuration for the current bid
- elementId (string): The ID of the placement element
- mediaTypes (array): Supported media types for this placement
- bids (array): All bid configurations for this placement
- Additional placement configuration properties
Return Value
Section titled “Return Value”- object: The modified bid request object
- null or undefined: Skip this bid request entirely
Related Concepts
Section titled “Related Concepts”- Bid Config Extension: Learn about bidder configuration
- Placements: Learn about placement configuration
- reducePlacementConfig: Modify placement configuration
- handlePriorityCreative: Handle priority creative behavior
- handleEmptyGoogle: Handle empty Google responses
- isDisabled: Check if htag is disabled