Using GAM - Official Prebid Example
When not using GAM, you need to write more content for the render function. If using GAM, these steps will be greatly simplified as GAM handles them automatically. Here's a simple example and link to the official documentation.
First, you need to create your Line Item in GAM and set ad display conditions and delivery rules. Here's the official documentation link for Line Items.
Using the pbjs.setTargetingForGPTAsync method, Prebid.js will automatically set the winning bid ad information to GPT (Google Publisher Tags) ad slots, then load the ad information into the ad slots:
pbjs.que.push(function() {
pbjs.setTargetingForGPTAsync();
googletag.pubads().refresh();
});For ad slot rendering, GAM will use the googletag.display method to trigger ad display for each specified ad container set in <div>. This method informs GPT to load and display the corresponding ad in the specified container, thus completing the entire process from bidding to display:
googletag.cmd.push(function() {
googletag.display('div-1');
});
googletag.cmd.push(function() {
googletag.display('div-2');
});Last updated