Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion integrationExamples/gpt/airgridRtdProvider_example.html
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@
apiKey: "key123",
accountId: "sdk",
publisherId: "pub123",
bidders: ["appnexus", "pubmatic"],
Copy link
Author

@naripok naripok May 22, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ydennisy this is needed so the data will be passed to the bidders.
I'm including this here so the example will be fully functional.
Please, let me know if you think I shouldn't.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is fine; only the js cannot refer to specific bidders

},
},
],
Expand Down Expand Up @@ -108,7 +109,7 @@
var gads = document.createElement("script");
gads.async = true;
gads.type = "text/javascript";
gads.src = 'https://securepubads.g.doubleclick.net/tag/js/gpt.js';
gads.src = "https://securepubads.g.doubleclick.net/tag/js/gpt.js";
var node = document.getElementsByTagName("script")[0];
node.parentNode.insertBefore(gads, node);
})();
Expand Down
41 changes: 28 additions & 13 deletions modules/airgridRtdProvider.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { submodule } from '../src/hook.js';
import {
deepSetValue,
deepAccess,
mergeDeep,
} from '../src/utils.js';
import { getGlobal } from '../src/prebidGlobal.js';
import { getStorageManager } from '../src/storageManager.js';
Expand Down Expand Up @@ -80,28 +81,42 @@ function setAudiencesToAppNexusAdUnits(adUnits, audiences) {

/**
* Pass audience data to configured bidders, using ORTB2
* @param {Object} bidConfig
* @param {Object} rtdConfig
* @param {Array} audiences
* @return {{}} a map from bidder code to ORTB2 config
* @return {void}
*/
export function setAudiencesAsBidderOrtb2(rtdConfig, audiences) {
export function setAudiencesAsBidderOrtb2(bidConfig, rtdConfig, audiences) {
const bidders = deepAccess(rtdConfig, 'params.bidders');
if (!bidders || bidders.length === 0 || !audiences || audiences.length === 0) return;

const keywords = audiences.map(
const agOrtb2 = {};

const agKeywords = audiences.map(
(audienceId) => `perid=${audienceId}`
).join(',');
deepSetValue(agOrtb2, 'user.keywords', agKeywords);

config.mergeBidderConfig({
bidders: bidders,
config: {
ortb2: {
site: {
keywords,
}
}
// Is this correct?
const agUserData = [
{
id: String(AG_TCF_ID),
name: 'airgrid',
segment: audiences.map((audienceId) => {
return {
id: audienceId,
name: `audience_${audienceId}`,
value: audienceId,
};
})
}
})
]
deepSetValue(agOrtb2, 'user.data', agUserData);

const bidderConfig = Object.fromEntries(
bidders.map((bidder) => [bidder, agOrtb2])
)
mergeDeep(bidConfig?.ortb2Fragments?.bidder, bidderConfig)
}

export function setAudiencesUsingAppNexusAuctionKeywords(audiences) {
Expand Down Expand Up @@ -141,7 +156,7 @@ export function passAudiencesToBidders(
const audiences = getMatchedAudiencesFromStorage();
if (audiences.length > 0) {
setAudiencesUsingAppNexusAuctionKeywords(audiences);
setAudiencesAsBidderOrtb2(rtdConfig, audiences)
setAudiencesAsBidderOrtb2(bidConfig, rtdConfig, audiences)
if (adUnits) {
setAudiencesToAppNexusAdUnits(adUnits, audiences);
}
Expand Down