Skip to content

Commit

Permalink
Contxtful RTD Provider : add ORTB2 support (#11497)
Browse files Browse the repository at this point in the history
* contxtfulRtdProvider: update the Contxtful Rtd module

* contxtfulRtdProvider: update the GPT example

* contxtfulRtdProvider: update the tests

* contxtfulRtdProvider: refresh the documentation

* contxtfulRtdProvider: fix getTargetingData unit test

* contxtfulRtdProvider: revert out-of-scope changes

* contxtfulRtdProvider: revert out-of-scope changes

* contxtfulRtdProvider: sync docs with content on prebid.github.io

* contxtfulRtdProvider: improve header style

* contxtfulRtdProvider: improve sentences

* contxtfulRtdProvider: remove spurious text

* contxtfulRtdProvider: trigger build

* contxtfulRtdProvider: fix multi-line row in .md file

---------

Co-authored-by: Sebastien Boisvert <[email protected]>
  • Loading branch information
sebastienrufiange and sebhtml committed May 29, 2024
1 parent 8681fb9 commit b15af76
Show file tree
Hide file tree
Showing 4 changed files with 825 additions and 183 deletions.
261 changes: 191 additions & 70 deletions integrationExamples/gpt/contxtfulRtdProvider_example.html
Original file line number Diff line number Diff line change
@@ -1,91 +1,212 @@
<!DOCTYPE html>
<html>

<head>
<script src="http://localhost:9999/build/dev/prebid.js" async></script>
<script async src="https://www.googletagservices.com/tag/js/gpt.js"></script>
<script async>
const FAILSAFE_TIMEOUT = 8000;
const PREBID_TIMEOUT = 5000;
<script async src=
"https://www.googletagservices.com/tag/js/gpt.js"></script>
<script async src="http://localhost:9999/build/dev/prebid.js"></script>
<title>Contxtful Rtd Provider Example</title>
<script>
var div1Sizes = [
[300, 250],
[300, 600]
];
var div2Sizes = [
[728, 90 ],
[970, 250]
];

var PREBID_TIMEOUT = 1000;
var FAILSAFE_TIMEOUT = 3000;

var adUnits = [
{
code: '/19968336/header-bid-tag-0',
mediaTypes: {
banner: {
sizes: div1Sizes
},
},

const bidders = [
bids: [
{
bidder: 'appnexus',
params: {
placementId: 13144370
placementId: 13144370,
},
},
{
bidder: 'rubicon',
params: {
accountId: 14062,
siteId: 70608,
zoneId: 498816,
},
},
{
bidder: 'sharethrough',
params: {

placementId: 13144370,
// REQUIRED - The placement key
pkey: 'LuB3vxGGFrBZJa6tifXW4xgK',

// OPTIONAL - Blocked Advertiser Domains
badv: ['domain1.com', 'domain2.com'],

// OPTIONAL - Blocked Categories (IAB codes)
bcat: ['IAB1-1', 'IAB1-2'],

// OPTIONAL - default bid floor, if not specified in bid request (USD)
floor: 0.1,
}
},
],
},
{
code: '/19968336/header-bid-tag-1',
mediaTypes: {
banner: {
sizes: div2Sizes,
}
];
},

var adUnits = [
bids: [
{
code: 'div-gpt-ad-1460505748561-0',
mediaTypes: {
banner: {
sizes: [[300, 250], [300, 600]],
}
bidder: 'rubicon',
params: {
accountId: 14062,
siteId: 70608,
zoneId: 498816,
},
bids: bidders,
}
];


var pbjs = pbjs || {};
pbjs.que = pbjs.que || [];
var googletag = googletag || {};
googletag.cmd = googletag.cmd || [];
googletag.cmd.push(function () {
googletag.pubads().disableInitialLoad();
googletag.defineSlot('/19968336/header-bid-tag-0', [[300, 250], [300, 600]], 'div-gpt-ad-1460505748561-0').addService(googletag.pubads());
googletag.pubads().enableSingleRequest();
googletag.enableServices();
},
{
bidder: 'sharethrough',
params: {

placementId: 13144370,
// REQUIRED - The placement key
pkey: 'LuB3vxGGFrBZJa6tifXW4xgK',

// OPTIONAL - Blocked Advertiser Domains
badv: ['domain1.com', 'domain2.com'],

// OPTIONAL - Blocked Categories (IAB codes)
bcat: ['IAB1-1', 'IAB1-2'],

// OPTIONAL - default bid floor, if not specified in bid request (USD)
floor: 0.1,
}
},
]
},
];

var pbjs = pbjs || {};
pbjs.que = pbjs.que || [];

var googletag = googletag || {};
googletag.cmd = googletag.cmd || [];
googletag.cmd.push(function () {
googletag.pubads().disableInitialLoad();
});

pbjs.que.push(function() {
pbjs.setConfig({
debug: true,
realTimeData: {
auctionDelay: 100,
dataProviders: [
{
name: 'contxtful',
waitForIt: true,
params:
{
'version': 'Contact [email protected] for the API version',
'customer': 'Contact [email protected] for the customer ID',
'hostname': 'api.receptivity.io',
'adServerTargeting': true,
'bidders': ['sharethrough']
}
}
]}
});

pbjs.addAdUnits(adUnits);

// Initial bids
pbjs.requestBids({
bidsBackHandler: initAdserver,
timeout: PREBID_TIMEOUT
});
});

function refreshBids() {
pbjs.que.push(function () {
pbjs.requestBids({
bidsBackHandler: initAdserver,
timeout: PREBID_TIMEOUT,
});
});
}

function initAdserver() {
googletag.cmd.push(function () {
pbjs.que.push(function () {
pbjs.setConfig({
debug: true,
realTimeData: {
auctionDelay: 100,
dataProviders: [
{
name: "contxtful",
waitForIt: true,
params: {
version: "Contact [email protected] for the API version",
customer: "Contact [email protected] for the customer ID"
}
}
]
}
});
pbjs.addAdUnits(adUnits);
pbjs.requestBids({
bidsBackHandler: sendAdserverRequest,
timeout: PREBID_TIMEOUT
});
pbjs.setTargetingForGPTAsync();
googletag.pubads().refresh();
});
});
}

function sendAdserverRequest() {
if (pbjs.adserverRequestSent) return;
pbjs.adserverRequestSent = true;
googletag.cmd.push(function () {
pbjs.que.push(function () {
pbjs.setTargetingForGPTAsync();
googletag.pubads().refresh();
});
});
}
setTimeout(function () {
initAdserver();
}, FAILSAFE_TIMEOUT);

setTimeout(function () {
sendAdserverRequest();
}, FAILSAFE_TIMEOUT);
googletag.cmd.push(function () {
googletag
.defineSlot('/19968336/header-bid-tag-0',
div1Sizes, 'div-1')
.addService(googletag.pubads());
googletag.pubads().enableSingleRequest();
googletag.enableServices();
});

</script>
</head>
googletag.cmd.push(function () {
googletag
.defineSlot('/19968336/header-bid-tag-1',
div2Sizes, 'div-2')
.addService(googletag.pubads());
googletag.pubads().enableSingleRequest();
googletag.enableServices();
});

</script>
</head>
<body>
<h2>Contxtful RTD Provider</h2>
<div id='div-gpt-ad-1460505748561-0'></div>
</div>
</body>
<h2>Contxtful Rtd Provider Example</h2>

<p><button onclick="refreshBids()">Refresh Ad Units</button></p>

<h5>Div-1</h5>
<div id='div-1'>
<script type='text/javascript'>
googletag.cmd.push(function() {
googletag.display('div-1');
});

</html>
</script>
</div>

<br>

<h5>Div-2</h5>
<div id='div-2'>
<script type='text/javascript'>
googletag.cmd.push(function() {
googletag.display('div-2');
});

</script>
</div>
</body>
</html>
Loading

0 comments on commit b15af76

Please sign in to comment.