Skip to content

Commit

Permalink
OpenX Adapter: Added support for Do Not Track & COPPA
Browse files Browse the repository at this point in the history
Renamed divs query param to divIds
Removed placementId
Updated Documentation
  • Loading branch information
Jimmy Tu committed Jul 14, 2018
1 parent ed28094 commit 0f2f07d
Show file tree
Hide file tree
Showing 3 changed files with 239 additions and 39 deletions.
12 changes: 10 additions & 2 deletions modules/openxBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {parse} from 'src/url';
const SUPPORTED_AD_TYPES = [BANNER, VIDEO];
const BIDDER_CODE = 'openx';
const BIDDER_CONFIG = 'hb_pb';
const BIDDER_VERSION = '2.1.2';
const BIDDER_VERSION = '2.1.3';

let shouldSendBoPixel = true;

Expand Down Expand Up @@ -226,7 +226,7 @@ function buildOXBannerRequest(bids, bidderRequest) {
let pids = utils._map(bids, bid => bid.params.placementId);
queryParams.aus = utils._map(bids, bid => utils.parseSizesInput(bid.sizes).join(',')).join('|');
queryParams.bc = bids[0].params.bc || `${BIDDER_CONFIG}_${BIDDER_VERSION}`;
queryParams.divs = utils._map(bids, bid => bid.adUnitCode).join(',');
queryParams.divIds = utils._map(bids, bid => bid.adUnitCode).join(',');

if (auids.some(auid => auid)) {
queryParams.auid = auids.join(',');
Expand All @@ -235,6 +235,14 @@ function buildOXBannerRequest(bids, bidderRequest) {
queryParams.pids = pids.join(',');
}

if (bids.some(bid => bid.params.doNotTrack)) {
queryParams.ns = 1;
}

if (bids.some(bid => bid.params.coppa)) {
queryParams.tfcd = 1;
}

bids.forEach(function (bid) {
if (bid.params.customParams) {
let customParamsForBid = utils._map(Object.keys(bid.params.customParams), customKey => formatCustomParms(customKey, bid.params.customParams));
Expand Down
114 changes: 78 additions & 36 deletions modules/openxBidAdapter.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,46 +10,88 @@ Maintainer: team-openx@openx.com

Module that connects to OpenX's demand sources

# Test Parameters
```
var adUnits = [
{
code: 'test-div',
sizes: [[728, 90]], // a display size
mediaTypes: {'banner': {}},
bids: [
{
bidder: 'openx',
params: {
placementId: '/123/abcdefg'
unit: '539439964',
delDomain: 'se-demo-d.openx.net'
}
}
]
},
{
code: 'video1',
sizes: [[640,480]],
mediaTypes: {'video': {}},
bids: [
{
bidder: 'openx',
params: {
unit: '539131525',
delDomain: 'zdo.com',
video: {
url: 'abc.com'
}
}
}
]
# Bid Parameters
## Banner

| Name | Scope | Type | Description | Example
| ---- | ----- | ---- | ----------- | -------
| `delDomain` | required | String | OpenX delivery domain provided by your OpenX representative. | "PUBLISHER-d.openx.net"
| `unit` | required | String | OpenX ad unit ID provided by your OpenX representative. | "1611023122"
| `customParams` | optional | Object | User-defined targeting key-value pairs. customParams applies to a specific unit. | `{key1: "v1", key2: ["v2","v3"]}`
| `customFloor` | optional | Number | Minimum price in USD. customFloor applies to a specific unit. For example, use the following value to set a $1.50 floor: 1.50 <br/><br/> **WARNING:**<br/> Misuse of this parameter can impact revenue | 1.50
| `doNotTrack` | optional | Boolean | Prevents advertiser from using data for this user. <br/><br/> **WARNING:**<br/> Request-level setting. May impact revenue. | true
| `coppa` | optional | Boolean | Enables Child's Online Privacy Protection Act (COPPA) regulations. | true

## Video

| Name | Scope | Type | Description | Example
| ---- | ----- | ---- | ----------- | -------
| `unit` | required | String | OpenX ad unit ID provided by your OpenX representative. | "1611023122"
| `delDomain` | required | String | OpenX delivery domain provided by your OpenX representative. | "PUBLISHER-d.openx.net"
| `openrtb` | optional | OpenRTB Impression | An OpenRtb Impression with Video subtype properties | `{ imp: [{ video: {mimes: ['video/x-ms-wmv, video/mp4']} }] }`


# Example
```javascript
var adUnits = [
{
code: 'test-div',
sizes: [[728, 90]], // a display size
mediaTypes: {'banner': {}},
bids: [
{
bidder: 'openx',
params: {
unit: '539439964',
delDomain: 'se-demo-d.openx.net',
customParams: {
key1: 'v1',
key2: ['v2', 'v3']
},
}
}
]
},
{
code: 'video1',
mediaTypes: {
video: {
playerSize: [640, 480],
context: 'instream'
}
},
bids: [{
bidder: 'openx',
params: {
unit: '1611023124',
delDomain: 'PUBLISHER-d.openx.net',
openrtb: {
imp: [{
video: {
mimes: ['video/x-ms-wmv, video/mp4']
}
}]
}
];
}
}]
}
];
```

# Configuration
Add the following code to enable user syncing. By default, Prebid.js version 0.34.0+ turns off user syncing through iframes.
OpenX strongly recommends enabling user syncing through iframes. This functionality improves DSP user match rates and increases the
OpenX bid rate and bid price. Be sure to call `pbjs.setConfig()` only once.

```javascript
pbjs.setConfig({
userSync: {
iframeEnabled: true
}
});
```

# Links
# Additional Details
[Banner Ads](https://docs.openx.com/Content/developers/containers/prebid-adapter.html)

[Video Ads](https://docs.openx.com/Content/developers/containers/prebid-video-adapter.html)
Expand Down
152 changes: 151 additions & 1 deletion test/spec/modules/openxBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ describe('OpenxAdapter', () => {

it('should send the adunit codes', () => {
const request = spec.buildRequests(bidRequestsWithMediaTypes);
expect(request[0].data.divs).to.equal(`${bidRequestsWithMediaTypes[0].adUnitCode},${bidRequestsWithMediaTypes[1].adUnitCode}`);
expect(request[0].data.divIds).to.equal(`${bidRequestsWithMediaTypes[0].adUnitCode},${bidRequestsWithMediaTypes[1].adUnitCode}`);
});

it('should send ad unit ids when any are defined', () => {
Expand Down Expand Up @@ -695,6 +695,156 @@ describe('OpenxAdapter', () => {
});
});
});

it('should not send a coppa query param when there are no coppa param settings in the bid requests', () => {
const bidRequestsWithoutCoppa = [{
bidder: 'openx',
params: {
unit: '11',
delDomain: 'test-del-domain',
coppa: false
},
adUnitCode: 'adunit-code',
mediaTypes: {
banner: {
sizes: [[300, 250], [300, 600]]
}
},
bidId: 'test-bid-id-1',
bidderRequestId: 'test-bid-request-1',
auctionId: 'test-auction-1'
}, {
bidder: 'openx',
params: {
unit: '22',
delDomain: 'test-del-domain'
},
adUnitCode: 'adunit-code',
mediaTypes: {
banner: {
sizes: [[728, 90]]
}
},
bidId: 'test-bid-id-2',
bidderRequestId: 'test-bid-request-2',
auctionId: 'test-auction-2'
}];
const request = spec.buildRequests(bidRequestsWithoutCoppa);
expect(request[0].data).to.not.have.any.keys('tfcd');
});

it('should send a coppa flag there is when there is coppa param settings in the bid requests', () => {
const bidRequestsWithCoppa = [{
bidder: 'openx',
params: {
unit: '11',
delDomain: 'test-del-domain',
coppa: false
},
adUnitCode: 'adunit-code',
mediaTypes: {
banner: {
sizes: [[300, 250], [300, 600]]
}
},
bidId: 'test-bid-id-1',
bidderRequestId: 'test-bid-request-1',
auctionId: 'test-auction-1'
}, {
bidder: 'openx',
params: {
unit: '22',
delDomain: 'test-del-domain',
coppa: true
},
adUnitCode: 'adunit-code',
mediaTypes: {
banner: {
sizes: [[728, 90]]
}
},
bidId: 'test-bid-id-2',
bidderRequestId: 'test-bid-request-2',
auctionId: 'test-auction-2'
}];
const request = spec.buildRequests(bidRequestsWithCoppa);
expect(request[0].data.tfcd).to.equal(1);
});

it('should not send a "no segmentation" flag there no DoNotTrack setting that is set to true', () => {
const bidRequestsWithDnt = [{
bidder: 'openx',
params: {
unit: '11',
delDomain: 'test-del-domain',
doNotTrack: false
},
adUnitCode: 'adunit-code',
mediaTypes: {
banner: {
sizes: [[300, 250], [300, 600]]
}
},
bidId: 'test-bid-id-1',
bidderRequestId: 'test-bid-request-1',
auctionId: 'test-auction-1'
}, {
bidder: 'openx',
params: {
unit: '22',
delDomain: 'test-del-domain'
},
adUnitCode: 'adunit-code',
mediaTypes: {
banner: {
sizes: [[728, 90]]
}
},
bidId: 'test-bid-id-2',
bidderRequestId: 'test-bid-request-2',
auctionId: 'test-auction-2'
}];
const request = spec.buildRequests(bidRequestsWithDnt);
expect(request[0].data).to.not.have.any.keys('ns');
});

it('should send a "no segmentation" flag there is any DoNotTrack setting that is set to true', () => {
const bidRequestsWithDnt = [{
bidder: 'openx',
params: {
unit: '11',
delDomain: 'test-del-domain',
doNotTrack: false
},
adUnitCode: 'adunit-code',
mediaTypes: {
banner: {
sizes: [[300, 250], [300, 600]]
}
},
bidId: 'test-bid-id-1',
bidderRequestId: 'test-bid-request-1',
auctionId: 'test-auction-1'
}, {
bidder: 'openx',
params: {
unit: '22',
delDomain: 'test-del-domain',
doNotTrack: true
},
adUnitCode: 'adunit-code',
mediaTypes: {
banner: {
sizes: [[728, 90]]
}
},
bidId: 'test-bid-id-2',
bidderRequestId: 'test-bid-request-2',
auctionId: 'test-auction-2'
}];
const request = spec.buildRequests(bidRequestsWithDnt);
expect(request[0].data.ns).to.equal(1);
});
});

describe('buildRequests for video', () => {
Expand Down

0 comments on commit 0f2f07d

Please sign in to comment.