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

Add custom targeting key-vals without using `pbjs.bidderSettings`?

Open tomraa opened this issue 8 years ago • 3 comments

Type of issue

Question

Description

We'd like to add custom key/val pairs onto the GAM/DFP request, but it appears that the only way to do this is use pbjs.bidderSettings.standard.adServerTargeting which prevents any of the standard hb_ ones being added. Is there a way to keep those and add on any new ones we want on there?

We'll be coming to use Deals soon, so if we start to manage all of the targeting with pbjs.bidderSettings, will any bidders' deal IDs also not be added automatically, so we'd have to start getting those manually and adding them ourselves? <- I cannot initially see how this would be done, as pbjs.bidderSettings seems to not work after the auction has started, so custom targeting needs to be set before any responses are received.

tomraa avatar Oct 23 '18 14:10 tomraa

If the extra key/val pairs are for a single adapter, the targeting can be added in as adapter-specific without stomping on the standard values. Otherwise, you can just add it to the standard section and specify all the keys. Here's the block of them copied from http://prebid.org/dev-docs/publisher-api-reference.html

pbjs.bidderSettings = {
    standard: {
        adserverTargeting: [{
            key: "hb_bidder",
            val: function(bidResponse) {
                return bidResponse.bidderCode;
            }
        }, {
            key: "hb_adid",
            val: function(bidResponse) {
                return bidResponse.adId;
            }
        }, {
            key: "hb_pb",
            val: function(bidResponse) {
                return bidResponse.pbMg;
            }
        }, {
            key: 'hb_size',
            val: function (bidResponse) {
                return bidResponse.size;
            }
        }, {
            key: 'hb_source',
            val: function (bidResponse) {
                return bidResponse.source;
            }
        }, {
            key: 'hb_format',
            val: function (bidResponse) {
                return bidResponse.mediaType;
            }
        }, {
            key: 'hb_cache_id',
            val: function (bidResponse) {
                return bidResponse.videoCacheKey;
            }
        }, {
            key: 'hb_uuid',
            val: function (bidResponse) {
                return bidResponse.videoCacheKey;
            }
        }]
    }
}

You may also have to add any required bidder-specific keys.

There's a feature you're implying here which is a setting that adds to standard rather than overwriting. Can see that being useful... e.g. pbjs.bidderSettings.standard.adServerTargetingAdditions. Willing to consider a PR in that direction.

bretg avatar Oct 23 '18 16:10 bretg

Thanks for confirming that is the case. We'd definitely benefit from having an adServerTargetingAdditions feature so will open a PR if we build it. cc: @samwhitecoull

tomraa avatar Oct 24 '18 14:10 tomraa

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] avatar Nov 07 '18 14:11 stale[bot]