Skip to content

Commit

Permalink
OpenX Adapter: Added support for Do Not Track & COPPA (prebid#2838)
Browse files Browse the repository at this point in the history
Renamed divs query param to divIds
Removed placementId
Updated Documentation
  • Loading branch information
jimee02 authored and florevallatmrf committed Sep 6, 2018
1 parent cc5a8a8 commit c8e8287
Show file tree
Hide file tree
Showing 3 changed files with 258 additions and 126 deletions.
18 changes: 11 additions & 7 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 All @@ -20,8 +20,8 @@ export const spec = {
code: BIDDER_CODE,
supportedMediaTypes: SUPPORTED_AD_TYPES,
isBidRequestValid: function (bidRequest) {
if (bidRequest.mediaTypes && bidRequest.mediaTypes.banner) {
return !!((bidRequest.params.unit || bidRequest.params.placementId) && bidRequest.params.delDomain);
if (utils.deepAccess(bidRequest, 'mediaTypes.banner') && bidRequest.params.delDomain) {
return !!bidRequest.params.unit || utils.deepAccess(bidRequest, 'mediaTypes.banner.sizes.length') > 0;
}

return !!(bidRequest.params.unit && bidRequest.params.delDomain);
Expand Down Expand Up @@ -223,16 +223,20 @@ function buildOXBannerRequest(bids, bidderRequest) {
let hasCustomParam = false;
let queryParams = buildCommonQueryParamsFromBids(bids, bidderRequest);
let auids = utils._map(bids, bid => bid.params.unit);
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 => encodeURIComponent(bid.adUnitCode)).join(',');

if (auids.some(auid => auid)) {
queryParams.auid = auids.join(',');
}
if (pids.some(pid => pid)) {
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) {
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
Loading

0 comments on commit c8e8287

Please sign in to comment.