This module is a simplified alternate installation mechanism for publishers that have Google Publisher Tag (GPT) ad calls in their pages. Here’s how it works:
Definitions:
Adding the module to a page is done by adding just one line of javascript:
The prebid.js file needs to be loaded before the GPT library loads, unless you’re willing to manage the timing with additional queue functions. The examples here assume the easiest integration, which is synchronous.
The prebid.js file must also be constructed so that it contains:
Create an AdUnits file and source control it in a separate local repository. E.g. my-prebid-config/pub123adUnits.js:
Notes:
Follow the basic build instructions on the Gihub repo’s main README. To include the module, an additional option must be added to the the gulp build command:
This command will build the following files:
If you’ve chosen to append the AdUnits right to the end of the package, use the command line to concatenate the files. e.g.
After testing, get your javascript file(s) out to your Content Delivery Network (CDN) as normal.
Note that there are more dynamic ways of combining these components for publishers or integrators ready to build a more advanced infrastructure.
The Google Ad Manager Express module adds one new function to Prebid:
This function initiates the scanning of the in-page Google Ad Manager slots, mapping them to Prebid AdUnits, kicking off the Prebid auction, and forwarding the results to Google Ad Manager.
The AdUnits argument is optional – if not provided it will look for AdUnits previously registered with pbjs.addAdUnits(). If no AdUnits can be found, it will return an error.
The practice of intercepting GPT ad calls has precedence in the industry, but may not work in all scenarios. The publisher assumes all risks:
1) Build a version of your prebid.js file
2) Append the following lines to the file:
var adUnits = [
{
code: '/111111/slot-name',
mediaTypes: {
banner: {
sizes: [[300,250]]
}
},
bids: [
{
bidder: 'rubicon',
params: { account: 1001, siteId: 113932, zoneId: 535510 }
}
}];
pbjs.express(adUnits);
3) Two things to note: first, the AdUnit.code field must match an actual GPT slot name. Second, the call to pbjs.express(adUnits)
is what kicks off header bidding.
4) Integrate your Prebid.js file into the page
<meta charset="UTF8">
<html>
<head>
// prebid.js needs to be loaded synchronously to make sure GPT doesn't fire before header bidding takes place
<script src="https://some.hosting.domain/path/myprebid.js"></script>
// it's assumed that the above myprebid.js file contains:
// - a definition for a prebid.js adunit with a `code` of 'slot-name' or 'div-name'
// - a call to pbjs.express(adUnits)
<script type="text/javascript" src="https://securepubads.g.doubleclick.net/tag/js/gpt.js" async="true"></script>
<script type ="text/javascript">
var googletag = googletag || {};
googletag.cmd = googletag.cmd || [];
</script>
<script type="text/javascript">
googletag.cmd.push(function() {
googletag.defineSlot('/111111/slot-name', [[300, 250]], 'div-name').addService(googletag.pubads());
googletag.pubads().enableSingleRequest();
googletag.pubads().enableAsyncRendering();
googletag.enableServices();
});
</script>
</head>
<body>
<h2>Express Test</h2>
<div id='div-name'>
<script type='text/javascript'>
googletag.cmd.push(function() { googletag.display('div-name'); });
</script>
</div>
</body>
</html>
More about Google Publisher Tags