Prebid.js icon indicating copy to clipboard operation
Prebid.js copied to clipboard

Targeting issue: adserverTargeting ignored

Open bretg opened this issue 9 years ago • 7 comments

Type of issue

Bug

Description

We found that our CPM function in bidderSettings.adserverTargeting was being ignored and instead the "medium" price granularity is used. The issue is that getAllTargeting() is calling both getWinningBidTargeting() and getBidLandscapeTargeting(). The first function returns an in-correct but complete set of attributes and values. The winning hb_pb is incorrect (it's based on the medium granularity price bucket), but the hb_pb_rubicon is at least correct. Then getBidLandscapeTargeting() adds a second set of hb_*_rubicon values, which ends up overwriting the first set.

Steps to reproduce

  1. Create a test page with a bidderSettings that defines a custom price bucket function. Here's the one we were using when the issue was discovered. Note that the currencyRate isn't a core part of the problem, but is part of how we found it.
        pbjs.bidderSettings = {
            rubicon: {
               bidCpmAdjustment : function(bidCpm, bid){
                  var currencyRate = 111.32;
                  return bidCpm * currencyRate;
           },
            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) {
                        var cpm = bidResponse.cpm;
                        if (cpm <= 800.00) {
                            return (Math.floor(cpm * 0.2) / 0.2).toFixed(2);
                        } else {
                            return '800.00';
                        }
                    }
                }
            ]}
        }
  1. With debug logging on, send in a bid with a value that ends up being > 20 after the cpmAdjustment
  2. enableSendAllBids()

Expected results

Say the Rubicon's the only bidder with a bid of 1.71, it gets adjusted by bidCpmAdjustment to 190.36

  1. the browser console should show
12408.js:4 MESSAGE: Attempting to set key value for slot: div-gpt-ad-1494311114062-0 key: hb_bidder value: rubicon
12408.js:4 MESSAGE: Attempting to set key value for slot: div-gpt-ad-1494311114062-0 key: hb_adid value: 22dd7f3f8bf614
12408.js:4 MESSAGE: Attempting to set key value for slot: div-gpt-ad-1494311114062-0 key: hb_pb value: 190.00
12408.js:4 MESSAGE: Attempting to set key value for slot: div-gpt-ad-1494311114062-0 key: hb_size value: 300x250
12408.js:4 MESSAGE: Attempting to set key value for slot: div-gpt-ad-1494311114062-0 key: hb_size_rubicon value: 300x250
12408.js:4 MESSAGE: Attempting to set key value for slot: div-gpt-ad-1494311114062-0 key: hb_adid_rubicon value: 22dd7f3f8bf614
12408.js:4 MESSAGE: Attempting to set key value for slot: div-gpt-ad-1494311114062-0 key: hb_pb_rubicon value: 190.00
12408.js:4 MESSAGE: Attempting to set key value for slot: div-gpt-ad-1494311114062-0 key: hb_bidder_rubicon value: rubicon

  1. What goes to the ad server should be:
hb_pb=190.00&hb_pb_rubicon=190.00&[...]

Actual results

The bid is 1.71, it gets adjusted by bidCpmAdjustment to 190.36

  1. the browser console shows:
12408.js:4 MESSAGE: Attempting to set key value for slot: div-gpt-ad-1494311114062-0 key: hb_bidder value: rubicon
12408.js:4 MESSAGE: Attempting to set key value for slot: div-gpt-ad-1494311114062-0 key: hb_adid value: 22dd7f3f8bf614
12408.js:4 MESSAGE: Attempting to set key value for slot: div-gpt-ad-1494311114062-0 key: hb_pb value: 20.00
12408.js:4 MESSAGE: Attempting to set key value for slot: div-gpt-ad-1494311114062-0 key: hb_size value: 300x250
12408.js:4 MESSAGE: Attempting to set key value for slot: div-gpt-ad-1494311114062-0 key: hb_size_rubicon value: 300x250
12408.js:4 MESSAGE: Attempting to set key value for slot: div-gpt-ad-1494311114062-0 key: hb_adid_rubicon value: 22dd7f3f8bf614
12408.js:4 MESSAGE: Attempting to set key value for slot: div-gpt-ad-1494311114062-0 key: hb_pb_rubicon value: 190.00
12408.js:4 MESSAGE: Attempting to set key value for slot: div-gpt-ad-1494311114062-0 key: hb_bidder_rubicon value: rubicon
12408.js:4 MESSAGE: Attempting to set key value for slot: div-gpt-ad-1494311114062-0 key: hb_adid_rubicon value: 22dd7f3f8bf614
12408.js:4 MESSAGE: Attempting to set key value for slot: div-gpt-ad-1494311114062-0 key: hb_pb_rubicon value: 20.00
12408.js:4 MESSAGE: Attempting to set key value for slot: div-gpt-ad-1494311114062-0 key: hb_size_rubicon value: 300x250
12408.js:4 MESSAGE: Attempting to set key value for slot: div-gpt-ad-1494311114062-0 key: hb_bidder_rubicon value: rubicon

Note two problems:

  • hb_pb is 20 rather than 190
  • there are two sets of hb_*_rubicon targeting attributes
  1. What goes to the ad server is:
hb_pb=20.00&hb_pb_rubicon=20.00&[...]

Platform details

Prebid 0.24.1 (and possibly earlier)

Other information

The workaround is to not use a CPM function in adserverTargeting, and instead use a customPriceGranularity. This is fine for most uses, but isn't a generic solution.

bretg avatar Jun 05 '17 17:06 bretg

Set alwaysUseBid in bidder settings and don't use enableSendAllBids(), you should get your custom keys along with standard keys (if bidderSettings.bidder.sendStandardTargeting = true) Then the bid landscape values won't overwrite the bidder settings values.

protonate avatar Jun 06 '17 06:06 protonate

@mjacobsonny - is this the way we want users to be able to override the standard ad server keys in the long run? e.g. to set hb_deal_rubicon, we'd instruct the publisher to turn off enableSendAllBids() and turn on alwaysUseBid for all bidders. This seems counter-intuitive, questioning the meaning of enableSendAllBids.

bretg avatar Jun 15 '17 02:06 bretg

I also agree that this is confusing. The original intention of adserverTargeting was that it would override any keys with it's final value regardless of the "system" wide settings are - so it's confusing to not continue that pattern.

mkendall07 avatar Jun 20 '17 16:06 mkendall07

@bretg -- No, this is a bug, as identified above by @mkendall07. The right behavior seems like it should be:

  • Always send standard keys, in addition to any keys set in adserverTargeting
  • If adserverTargeting overrides any standard key, send the overridden value

mjacobsonny avatar Jun 20 '17 16:06 mjacobsonny

I think the expected results here should be: hb_pb=20.00&hb_pb_rubicon=190.00&[...] Instead of: hb_pb=190.00&hb_pb_rubicon=190.00&[...]

Because you did not override the hb_pb key and thus medium granularity applies.

mkendall07 avatar Sep 19 '17 02:09 mkendall07

Upon further review, if you override the hb_pb key as well, this works as expected. Does that solve for the use case here? The root issue is treating hb_pb_${bidder} as as "sort of" standard keys. I think we need to make these defacto standard keys and refactor targeting.js but this would take a bit of work.

mkendall07 avatar Sep 19 '17 02:09 mkendall07

this should be resolved in 1.x now

mkendall07 avatar Feb 23 '18 21:02 mkendall07