prebid / Prebid.js

Setup and manage header bidding advertising partners without writing code or confusing line items. Prebid.js is open source and free.
https://docs.prebid.org
Apache License 2.0
1.28k stars 2.05k forks source link

Prebid not rendering winning bidder's creative #1269

Closed jamesfebin closed 7 years ago

jamesfebin commented 7 years ago

I am using the latest version of Prebid.

I was trying to setup prebid. I am able to receive bids, however the winning bid is not picked or the respective line item is not triggered, the ad of the bidder is not displayed. Instead it goes back to a fallback line items I created for $0.00 . The prebid console stops at Attempting to set key value for slot XXXX and then nothing, no winners, no render ad as shown in the below link Look at the following image

console

Here hb_pb value is 0.40. But the respective line item is not selected even though there are line items with hb_pb of 0.36, 0.39 etc. In the delivery diagnostics, I don't see the hb_pb request going to dfp. I am not sure why the case is. Please check the image. line_item

Here is my prebid code.

var PREBID_TIMEOUT = 1000;

var adUnits = [{
                code: 'XXXX',
                sizes: [
                    [300, 250]
                ],
                bids: [{
                    bidder: 'XXXX',
                    params: {
                        id: YYYYY
                    }
                }, {
                    bidder: 'XXXXX',
                    params: {
                        placementId: 'YYYYY'
                    }
                }]
            }];

            var pbjs = pbjs || {};
            pbjs.que = pbjs.que || [];

            var googletag = googletag || {};
            googletag.cmd = googletag.cmd || [];
            googletag.cmd.push(function() {

                googletag.pubads().disableInitialLoad();
            });

            pbjs.que.push(function() {

      pbjs.aliasBidder('XXX', 'YYY');
                pbjs.addAdUnits(adUnits);
                pbjs.requestBids({
                    bidsBackHandler: sendAdserverRequest
                });
            });

            function sendAdserverRequest() {
                if (pbjs.adserverRequestSent) return;
                pbjs.adserverRequestSent = true;
                googletag.cmd.push(function() {

                    pbjs.que.push(function() {
                        pbjs.setTargetingForGPTAsync();
                        googletag.pubads().refresh();
                    });
                });
            }

            setTimeout(function() {
                sendAdserverRequest();
            }, PREBID_TIMEOUT);

            (function() {
                var gads = document.createElement('script');
                gads.async = true;
                gads.type = 'text/javascript';
                var useSSL = 'https:' == document.location.protocol;
                gads.src = (useSSL ? 'https:' : 'http:') +
                    '//www.googletagservices.com/tag/js/gpt.js';
                var node = document.getElementsByTagName('script')[0];
                node.parentNode.insertBefore(gads, node);
            })();

            googletag.cmd.push(function() {
                googletag.defineSlot('/XXXXX/YYYY, [300, 250], 'XXXXXXX').addService(googletag.pubads());
                googletag.pubads().enableSingleRequest();
                googletag.enableServices();

            });
aneuway2 commented 7 years ago

Looks like the KVs are never getting to google. Do you by chance have the googletag.pubads().refresh() call (you might even be able to call this manually in the browser console to see if the KVs get set

jamesfebin commented 7 years ago

Actually I am using the refresh function in the code.

  pbjs.que.push(function() {
                        pbjs.setTargetingForGPTAsync();
                        googletag.pubads().refresh();
                    });
aneuway2 commented 7 years ago

@jamesfebin is that in the bidsbackhandler? Otherwise i'd think you'd need an onEvent handler on the auctionEnd event before firing that off.

pbjs.que.push(function() {
    pbjs.onEvent('auctionEnd', function() { 
        pbjs.setTargetingForGPTAsync();
            googletag.pubads().refresh();
    });      
});

( I also should have asked if you also have a googletag.disableInitialLoad() in place as well )

jamesfebin commented 7 years ago

I have satisfied all the requirements you have mentioned. One more thing I failed to mention. I am a third party who is implemented header bidding for a publisher through a javascript in the header. Does that change anything?