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

Blank and Multiple Bids are passing in dfp Prev_scp #1558

Closed gauravparashar12 closed 6 years ago

gauravparashar12 commented 7 years ago

Implementation Issue :I have implemented prebid on my website with multiple partners But i have facing empty parameters and sometimes double bids for single slot .I have attached the screenshot screenshot from 2017-09-04 11 23 42

and I have implemented following code for prebid `var PREBID_TIMEOUT=1000;

function initAdserver() {
        if (pbjs.initAdserverSet) return;
        /*load GPT library here*/
        (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);
        })();
        pbjs.initAdserverSet = true; 
    };

        /*Load the Prebid Javascript Library Async. We recommend loading it immediately after
    the initAdserver() and setTimeout functions.*/
    (function() {
        var d = document, pbs = d.createElement('script'), pro = d.location.protocol;
        pbs.type = 'text/javascript';
        pbs.src = 'https://central.bhaskar.com/js_ads/ads/header-bidding/bhaskar/library/prebid.js';
        var target = document.getElementsByTagName('head')[0];
        target.insertBefore(pbs, target.firstChild);
    })();

    pbjs.que.push(function(){

        const customConfigObject = {
          "buckets" : [{
              "precision": 2, 
              "min" : 0.01,
              "max" : 10.00,
              "increment" : 0.01
            },{
              "precision": 2, 
              "min" : 10.01,
              "max" : 20.00,
              "increment" : 0.01
            }]
        };
       pbjs.setPriceGranularity(customConfigObject);

/add the adUnits/ pbjs.addAdUnits(adUnits);

         /*register a callback handler*/
        pbjs.addCallback('adUnitBidsBack', function(adUnitCode){
        });

        pbjs.requestBids({

            /* The bidsBack function will be called when either timeout is
             reached, or when all bids come back, whichever happens sooner.
             */
       bidsBackHandler: function(bidResponses) {
                /*pbjs.setTargetingForGPTAsync();*/
                initAdserver();
            }
        });

         pbjs.bidderSettings = {
            pubmatic: {
                sendStandardTargeting: false,
                suppressEmptyKeys:true,
                alwaysUseBid:true,
                adserverTargeting: [
                  {
                      key: "hb_size_pubmatic",
                      val: function(bidResponse) {
                          return bidResponse.size;
                      }
                  },{
                      key: "hb_adid_pubmatic",
                      val: function(bidResponse) {
                          return bidResponse.adId;
                      }
                    },{
                        key: "hb_pb_pubmatic",
                        val: function(bidResponse) {
                            return bidResponse.pbHg;
                        }
                    },{
                        key: "hp_bidder_pubmatic",
                        val: function(bidResponse) {
                            return 'pubmatic';
                        }
                    },{
                      key: "hb_bidder_pubmatic",
                      val: function(bidResponse) {
                          return "pubmatic";
                      }
                    }
                ]
             },appnexus: {
                 sendStandardTargeting: false,
                suppressEmptyKeys:true,
                alwaysUseBid:true,

                 adserverTargeting: [
                   {
                       key: "hb_size_appnexus",
                       val: function(bidResponse) {
                          return bidResponse.size;
                       }
                   }, {
                       key: "hb_adid_appnexus",
                       val: function(bidResponse) {
                           return bidResponse.adId;
                       }
                     },
                     {
                         key: "hb_pb_appnexus",
                         val: function(bidResponse) {
                            return bidResponse.pbHg;
                         }
                     },{
                      key: "hb_bidder_appnexus",
                      val: function(bidResponse) {
                          return "appnexus";
                      }
                    }

                 ]
              },rubicon: {
                sendStandardTargeting: false,
                suppressEmptyKeys:true,
                alwaysUseBid:true,
                adserverTargeting: [
                  {
                      key: "hb_size_rubicon",
                      val: function(bidResponse) {
                          return bidResponse.size;
                      }
                  },{
                      key: "hb_adid_rubicon",
                      val: function(bidResponse) {
                            return bidResponse.adId;
                      }
                    },{
                        key: "hb_pb_rubicon",
                        val: function(bidResponse) {
                            return bidResponse.pbHg;
                        }
                    },{
                      key: "hb_bidder_rubicon",
                      val: function(bidResponse) {
                          return "rubicon";
                      }
                    }
                ]
             },criteo: {
                 sendStandardTargeting: false,
                suppressEmptyKeys:true,
                alwaysUseBid:true,

                 adserverTargeting: [
                   {
                       key: "hb_size_criteo",
                       val: function(bidResponse) {
                           return bidResponse.size;
                       }
                   }, {
                       key: "hb_adid_criteo",
                       val: function(bidResponse) {
                           return bidResponse.adId;
                       }
                     },
                     {
                         key: "hb_pb_criteo",
                         val: function(bidResponse) {
                            var cpm = bidResponse.cpm;
                            return (Math.floor(cpm)/65).toFixed(2);
                         }
                     },{
                      key: "hb_bidder_criteo",
                      val: function(bidResponse) {
                          return "criteo";
                      }
                    }

                 ]
              }
        };

    });

`

bretg commented 7 years ago

Blank values are normal -- could be no-bids or timeouts.

Please post an example where there are two bids for a single slot?

bretg commented 7 years ago

If there's a problem, it may be related to the definition in bidderSettings of adserverTargeting and the issue reported https://github.com/prebid/Prebid.js/issues/1267

I recommend removing as much of the bidderSettings.adserverTargeting as possible. If you want to adjust bid values (like you're modifying hb_pb_criteo), try bidderSettings.bidCpmAdjustment rather than adserverTargeting.

gauravparashar12 commented 7 years ago

Hello @bretg you can see in the screenshot screenshot from 2017-09-07 19 15 49

bretg commented 7 years ago

Please help us understand why you're setting sendStandardTargeting to false and overridding everything with what amounts to the standard targeting?

1) there are known bugs with overridding standard targets.

2) modifying bid CPM should be done with bidderSettings.bidCpmAdjustment

manishdhiman commented 7 years ago

we are using custom standard targeting that is why we have to do false, otherwise it can pass values into hb_pb, which we have not created values into dfp lineitem.

bretg commented 7 years ago

@manishdhiman - the only custom value I'm seeing in the code above is the CPM for criteo. My point is that if that's the only customization, it should be done with bidderSettings.bidCpmAdjustment.

Otherwise, if there are other customizations not shown above, then you'll need to wait for #1267.

bretg commented 6 years ago

@manishdhiman - did this work for you? I'm going to close this out. You're welcome to re-open with addtitional detail if needed.