Prebid embedding test (serverless)

console.log('prebid template activated'); var adUnits = [ { code: 'test-div', mediaTypes: { banner: { sizes: [[300, 250]], }, }, bids: [ { bidder: 'appnexus', params: { placementId: 13144370 }, }, ] }, { code: 'test-div2', mediaTypes: { banner: { sizes: [[728, 90]], }, }, bids: [ { bidder: 'appnexus', params: { placementId: 13144370 }, }, ], }, ]; function renderAllAdUnits() { var winners = pbjs.getHighestCpmBids(); for (var i = 0; i < winners.length; i++) { renderOne(winners[i]); } } function renderOne(winningBid) { if (winningBid && winningBid.adId) { var div = document.getElementById(winningBid.adUnitCode); if (div) { let iframe = document.createElement('iframe'); iframe.frameBorder = '0'; div.appendChild(iframe); var iframeDoc = iframe.contentWindow.document; pbjs.renderAd(iframeDoc, winningBid.adId); } } } function send(bid) { var data = { placementId: bid.params[0].placementId, publisher_billing_uuid: bid.adserverTargeting.publisher_billing_uuid, bidId: bid.adId, requestId: bid.requestId, auctionId: bid.auctionId, transactionId: bid.transactionId, bidder: bid.bidder, originalCpm: bid.originalCpm, originalCurrency: bid.originalCurrency, cpm: bid.cpm, currency: bid.currency, adUnitCode: bid.adUnitCode, netRevenue: bid.netRevenue, dchain: bid.meta.dchain }; var http = new XMLHttpRequest(); var url = 'https://test.theenergygrid.com/endpoint'; http.open('POST', url, true); http.setRequestHeader('Content-Type', 'application/json;charset=UTF-8'); http.send(JSON.stringify(data)); } pbjs.setConfig({ userSync: { filterSettings: { iframe: { bidders: '*', // '*' represents all bidders filter: 'include' } } } }); pbjs.bidderSettings = { appnexus: { adserverTargeting: [ { key: "publisher_billing_uuid", // Use key configured in your adserver val: function (bidResponse) { return '123'; } } ] } }; pbjs.onEvent('bidWon', function (bid) { console.log('Bid won:', bid); send(bid); }); pbjs.que.push(function () { pbjs.addAdUnits(adUnits); pbjs.requestBids({ timeout: 2000, bidsBackHandler: renderAllAdUnits, }); });

Ads test page (Prebid, serverless mode)