This module enables bidder targeting and tracking at the ad server ad slot level.
This module is enabled by default if it’s compiled into your PBJS package. It will add the GPID along with the matching GAM ad unit name to each ad unit’s first-party data before bid requests are sent to the adapters.
Unlike many other modules, the GPT Pre-Auction Module is on by default if it’s compiled into the Prebid.js package.
Optional initialization parameters:
| Param | Required? | Type | Description | Example |
| enabled | no | boolean | allows turning off of module. Default value is true | true |
| useDefaultPreAuction | no | boolean | If true, use default behavior for determining GPID. Defaults to true. | true |
| customPreAuction | no | function | Custom function for defining the GPID. | |
| mcmEnabled | no | boolean | Removes extra network IDs when Multiple Customer Management is active. Default is false. | true |
For example:
pbjs.setConfig({
gptPreAuction: {
enabled: true, // enabled by default
useDefaultPreAuction: true,
customPreAuction: function(adUnit, adServerAdSlot, gptAdUnitPath) {
...
return "customGpid";
},
mcmEnabled: true
}
});
When this module is turned on, it uses the BEFORE_REQUEST_BIDS event to insert functionality that:
If GPT slot matching succeeds:
Here’s what the module does to define GPID:
The following customPreAuction function will work for many publishers. Assumptions:
If either of these isn’t the case, you’ll need to supply your own function.
pbjs.setConfig({
gptPreAuction: {
enabled: true, // enabled by default
customPreAuction: function(adUnit, adServerAdSlot, gptAdUnitPath) {
// confirm that GPT is set up
if (!(googletag && googletag.apiReady)) {
return;
}
// find all GPT slots with this name
var gptSlots = googletag.pubads().getSlots().filter(function(gpt) {
return gpt.getAdUnitPath() == gptAdUnitPath;
});
if (gptSlots.length==0) {
return; // should never happen
}
if (gptSlots.length==1) {
return adServerAdSlot;
}
// else the adunit code must be div id. append it.
return adServerAdSlot+"#"+adUnit.code;
}
}
});