Skip to content

Commit

Permalink
Fixes #998 Allow keyvalues, gender and age to be passed in PubMatic (#…
Browse files Browse the repository at this point in the history
…1213)

* Fixes #998 Allow keyvalues, gender and age to be passed in PubMatic's adapter

* Linting and make sure to define variables
  • Loading branch information
ptomasroos authored and protonate committed Jun 6, 2017
1 parent 67540e4 commit 36db4c0
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/adapters/pubmatic.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ var bidmanager = require('../bidmanager.js');
var PubmaticAdapter = function PubmaticAdapter() {
var bids;
var _pm_pub_id;
var _pm_pub_age;
var _pm_pub_gender;
var _pm_pub_kvs;
var _pm_optimize_adslots = [];
let iframe;

Expand All @@ -21,6 +24,9 @@ var PubmaticAdapter = function PubmaticAdapter() {
var bid = bids[i];
// bidmanager.pbCallbackMap['' + bid.params.adSlot] = bid;
_pm_pub_id = _pm_pub_id || bid.params.publisherId;
_pm_pub_age = _pm_pub_age || (bid.params.age || '');
_pm_pub_gender = _pm_pub_gender || (bid.params.gender || '');
_pm_pub_kvs = _pm_pub_kvs || (bid.params.kvs || '');
_pm_optimize_adslots.push(bid.params.adSlot);
}

Expand Down Expand Up @@ -51,11 +57,18 @@ var PubmaticAdapter = function PubmaticAdapter() {
content += '' +
'window.pm_pub_id = "%%PM_PUB_ID%%";' +
'window.pm_optimize_adslots = [%%PM_OPTIMIZE_ADSLOTS%%];' +
'window.kaddctr = "%%PM_ADDCTR%%;"' +
'window.kadgender = "%%PM_GENDER%%;"' +
'window.kadage = "%%PM_AGE%%;"' +
'window.pm_async_callback_fn = "window.parent.$$PREBID_GLOBAL$$.handlePubmaticCallback";';

content += '</scr' + 'ipt>';

var map = {};
map.PM_PUB_ID = _pm_pub_id;
map.PM_ADDCTR = _pm_pub_kvs;
map.PM_GENDER = _pm_pub_gender;
map.PM_AGE = _pm_pub_age;
map.PM_OPTIMIZE_ADSLOTS = _pm_optimize_adslots.map(function (adSlot) {
return "'" + adSlot + "'";
}).join(',');
Expand Down

0 comments on commit 36db4c0

Please sign in to comment.