Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dailymotion Bid Adapter: add support for user syncs & new fields #11603

Merged
merged 12 commits into from
Jun 4, 2024
70 changes: 67 additions & 3 deletions modules/dailymotionBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,14 +54,37 @@ function getVideoMetadata(bidRequest, bidderRequest) {
: Object.keys(parsedContentData.iabcat2),
id: videoParams.id || deepAccess(contentObj, 'id', ''),
lang: videoParams.lang || deepAccess(contentObj, 'language', ''),
livestream: typeof videoParams.livestream === 'number'
? !!videoParams.livestream
: !!deepAccess(contentObj, 'livestream', 0),
private: videoParams.private || false,
tags: videoParams.tags || deepAccess(contentObj, 'keywords', ''),
title: videoParams.title || deepAccess(contentObj, 'title', ''),
url: videoParams.url || deepAccess(contentObj, 'url', ''),
topics: videoParams.topics || '',
xid: videoParams.xid || '',
livestream: typeof videoParams.livestream === 'number'
? !!videoParams.livestream
: !!deepAccess(contentObj, 'livestream', 0),
isCreatedForKids: typeof videoParams.isCreatedForKids === 'boolean'
? videoParams.isCreatedForKids
: null,
context: {
siteOrAppCat: deepAccess(contentObj, 'cat', ''),
videoViewsInSession: (
typeof videoParams.videoViewsInSession === 'number' &&
videoParams.videoViewsInSession >= 0
)
? videoParams.videoViewsInSession
: null,
autoplay: typeof videoParams.autoplay === 'boolean'
? videoParams.autoplay
: null,
playerVolume: (
typeof videoParams.playerVolume === 'number' &&
videoParams.playerVolume >= 0 &&
videoParams.playerVolume <= 10
)
? videoParams.playerVolume
: null,
},
};

return videoMetadata;
Expand Down Expand Up @@ -111,6 +134,7 @@ export const spec = {
method: 'POST',
url: 'https://pb.dmxleo.com',
data: {
pbv: '$prebid.version$',
bidder_request: {
gdprConsent: {
apiVersion: deepAccess(bidderRequest, 'gdprConsent.apiVersion', 1),
Expand Down Expand Up @@ -139,6 +163,13 @@ export const spec = {
appBundle: deepAccess(bidderRequest, 'ortb2.app.bundle', ''),
appStoreUrl: deepAccess(bidderRequest, 'ortb2.app.storeurl', ''),
} : {}),
...(deepAccess(bidderRequest, 'ortb2.device') ? {
device: {
lmt: deepAccess(bidderRequest, 'ortb2.device.lmt', null),
ifa: deepAccess(bidderRequest, 'ortb2.device.ifa', ''),
atts: deepAccess(bidderRequest, 'ortb2.device.ext.atts', 0),
},
} : {}),
request: {
adUnitCode: deepAccess(bid, 'adUnitCode', ''),
auctionId: deepAccess(bid, 'auctionId', ''),
Expand All @@ -149,6 +180,8 @@ export const spec = {
mimes: bid.mediaTypes?.[VIDEO]?.mimes || [],
minduration: bid.mediaTypes?.[VIDEO]?.minduration || 0,
maxduration: bid.mediaTypes?.[VIDEO]?.maxduration || 0,
playbackmethod: bid.mediaTypes?.[VIDEO]?.playbackmethod || [],
plcmt: bid.mediaTypes?.[VIDEO]?.plcmt || 1, // Fallback to instream considering logic of `isBidRequestValid`
protocols: bid.mediaTypes?.[VIDEO]?.protocols || [],
skip: bid.mediaTypes?.[VIDEO]?.skip || 0,
skipafter: bid.mediaTypes?.[VIDEO]?.skipafter || 0,
Expand Down Expand Up @@ -177,6 +210,37 @@ export const spec = {
* @return {Bid[]} An array of bids which were nested inside the server.
*/
interpretResponse: serverResponse => serverResponse?.body ? [serverResponse.body] : [],

/**
* Retrieves user synchronization URLs based on provided options and consents.
*
* @param {object} syncOptions - Options for synchronization.
* @param {object[]} serverResponses - Array of server responses.
* @returns {object[]} - Array of synchronization URLs.
*/
getUserSyncs: (syncOptions, serverResponses) => {
if (!!serverResponses?.length && (syncOptions.iframeEnabled || syncOptions.pixelEnabled)) {
const iframeSyncs = [];
const pixelSyncs = [];

serverResponses.forEach((response) => {
(response.user_syncs || []).forEach((syncUrl) => {
if (syncUrl.type === 'image') {
pixelSyncs.push({ url: syncUrl.url, type: 'image' });
}

if (syncUrl.type === 'iframe') {
iframeSyncs.push({ url: syncUrl.url, type: 'iframe' });
}
});
});

if (syncOptions.iframeEnabled) return iframeSyncs;
return pixelSyncs;
}

return [];
},
};

registerBidder(spec);
62 changes: 54 additions & 8 deletions modules/dailymotionBidAdapter.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
# Overview
### Overview

```
Module Name: Dailymotion Bid Adapter
Module Type: Bidder Adapter
Maintainer: ad-leo-engineering@dailymotion.com
```

# Description
### Description

Dailymotion prebid adapter.
Supports video ad units in instream context.

# Configuration options
### Configuration options

Before calling this adapter, you need to at least set a video adUnit in an instream context and the API key in the bid parameters:

Expand All @@ -36,7 +36,29 @@ const adUnits = [

`apiKey` is your publisher API key. For testing purpose, you can use "dailymotion-testing".

# Test Parameters
#### User Sync

To enable user synchronization, add the following code. Dailymotion highly recommends using iframes and/or pixels for user syncing. This feature enhances DSP user match rates, resulting in higher bid rates and bid prices. Ensure that `pbjs.setConfig()` is called only once.

```javascript
pbjs.setConfig({
userSync: {
syncEnabled: true,
filterSettings: {
iframe: {
bidders: '*', // Or add dailymotion to your list included bidders
filter: 'include'
},
image: {
bidders: '*', // Or add dailymotion to your list of included bidders
filter: 'include'
},
},
},
});
```

### Test Parameters

By setting the following bid parameters, you'll get a constant response to any request, to validate your adapter integration:

Expand All @@ -61,7 +83,7 @@ const adUnits = [

Please note that failing to set these will result in the adapter not bidding at all.

# Sample video AdUnit
### Sample video AdUnit

To allow better targeting, you should provide as much context about the video as possible.
There are three ways of doing this depending on if you're using Dailymotion player or a third party one.
Expand Down Expand Up @@ -118,6 +140,10 @@ const adUnits = [
tags: 'tag_1,tag_2,tag_3',
title: 'test video',
topics: 'topic_1, topic_2',
isCreatedForKids: false,
videoViewsInSession: 1,
autoplay: false,
playerVolume: 8
}
}
}],
Expand All @@ -126,6 +152,12 @@ const adUnits = [
video: {
api: [2, 7],
context: 'instream',
mimes: ['video/mp4'],
minduration: 5,
maxduration: 30,
playbackmethod: [3],
plcmt: 1,
protocols: [7, 8, 11, 12, 13, 14]
startdelay: 0,
w: 1280,
h: 720,
Expand All @@ -147,10 +179,18 @@ Each of the following video metadata fields can be added in bids.params.video.
* `private` - True if video is not publicly available
* `tags` - Tags for the video, comma separated
* `title` - Video title
* `url` - URL of the content
* `topics` - Main topics for the video, comma separated
* `xid` - Dailymotion video identifier (only applicable if using the Dailymotion player)
* `isCreatedForKids` - [The content is created for children as primary audience](https://faq.dailymotion.com/hc/en-us/articles/360020920159-Content-created-for-kids)

The following contextual informations can also be added in bids.params.video.

If you already specify [First-Party data](https://docs.prebid.org/features/firstPartyData.html) through the `ortb2` object when calling [`pbjs.requestBids(requestObj)`](https://docs.prebid.org/dev-docs/publisher-api-reference/requestBids.html), we will fallback to those values when possible. See the mapping below.
* `videoViewsInSession` - Number of videos viewed within the current user session
* `autoplay` - Playback was launched without user interaction
* `playerVolume` - Player volume between 0 (muted, 0%) and 10 (100%)

If you already specify [First-Party data](https://docs.prebid.org/features/firstPartyData.html) through the `ortb2` object when calling [`pbjs.requestBids(requestObj)`](https://docs.prebid.org/dev-docs/publisher-api-reference/requestBids.html), we will collect the following values and fallback to bids.params.video values when applicable. See the mapping below.

| From ortb2 | Metadata fields |
|---------------------------------------------------------------------------------|-----------------|
Expand All @@ -161,8 +201,14 @@ If you already specify [First-Party data](https://docs.prebid.org/features/first
| `ortb2.site.content.livestream` | `livestream` |
| `ortb2.site.content.keywords` | `tags` |
| `ortb2.site.content.title` | `title` |

# Integrating the adapter
| `ortb2.site.content.url` | `url` |
| `ortb2.app.bundle` | N/A |
| `ortb2.app.storeurl` | N/A |
| `ortb2.device.lmt` | N/A |
| `ortb2.device.ifa` | N/A |
| `ortb2.device.ext.atts` | N/A |

### Integrating the adapter

To use the adapter with any non-test request, you first need to ask an API key from Dailymotion. Please contact us through **DailymotionPrebid.js@dailymotion.com**.

Expand Down
Loading