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

Override s2s cookieseturl #10

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from 5 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
165 changes: 165 additions & 0 deletions integrationExamples/gpt/prebidServer_linkrewrite_example.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,165 @@
<!DOCTYPE html>
<html lang="en">
<head>
<style type="text/css">
nav a {
display: inline-block;
color: black;
padding: 0.5em;
text-align: center;
border-radius: 0.5em;
text-decoration: none;
border: 1px solid black;
}
</style>

<script>
var PREBID_TIMEOUT = 2000;

var adUnits = [
{
code: 'test-div',
sizes: [[728,90]],
bids: [
{
bidder: 'rubicon',
params: {
accountId: 1001,
siteId: 113932,
zoneId: 535510
}
}
]
},
{
code: 'test-div2',
sizes: [[300,250]],
bids: [
{
bidder: 'rubicon',
params: {
accountId: 1001,
siteId: 113932,
zoneId: 535510
}
}
]
}
];

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

</script>
<!--<script type="text/javascript" src="http://ads.rubiconproject.com/prebid/1001.js" async></script>-->
Copy link

Choose a reason for hiding this comment

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

let's not reference our rubicon resources in the examples.

<script type="text/javascript" src="../../build/dev/prebid.js" async></script>

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

pbjs.que.push(function() {
pbjs.logging = true;
pbjs.setConfig({s2sConfig:{
// String (required): The account ID
// accountId: '0acfb8cd-48de-4102-b519-01d1898ab87e',
accountId: '1001',

// Boolean (required): Enables S2S - defaults to `false`.
enabled: true,

// Array[String] (required): List of bidder codes to enable for S2S.
// Note that these must have been included in the Prebid.js build
// from Step 2.
bidders: ['rubicon'],

// Number (optional): Timeout for bidders called via the S2S
// endpoint, in milliseconds. Default value is 1000.
timeout: 1000,

syncEndpoint: 'https://prebid-server.rubiconproject.com/cookie_sync',
Copy link

Choose a reason for hiding this comment

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

same - maybe something like https://my-prebid-server.myhost/com/cookie_sync


// String (optional): Adapter code for S2S. Defaults to 'prebidServer'.
adapter: 'prebidServer',

// String (optional): Will override the default endpoint for Prebid Server.
endpoint: 'https://pbs-qa.aws.rubiconproject.com/auction?url_override=rubiconproject.com&debug=1',
Copy link

Choose a reason for hiding this comment

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

same.


// String (optional): Will override the default cookieSet endpoint for Prebid Server.
/*cookieSetUrl : 'https://assets.rubiconproject.com/utils/cookieset/cs.js'*/
Copy link

Choose a reason for hiding this comment

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

same.

cookieSetUrl : 'cs.js'
}});

pbjs.addAdUnits(adUnits);
pbjs.enableSendAllBids();
pbjs.requestBids({
bidsBackHandler: sendAdserverRequest
});
});

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

setTimeout(function() {
sendAdserverRequest();
}, PREBID_TIMEOUT);
</script>

<script>
(function () {
var gads = document.createElement('script');
gads.async = true;
gads.type = 'text/javascript';
var useSSL = 'https:' == document.location.protocol;
gads.src = (useSSL ? 'https:' : 'http:') +
'//www.googletagservices.com/tag/js/gpt.js';
var node = document.getElementsByTagName('script')[0];
node.parentNode.insertBefore(gads, node);
})();
</script>

<script>
googletag.cmd.push(function() {
googletag.defineSlot('/112115922/FL_PB_MedRect', [[728,90]], 'test-div').addService(googletag.pubads());
googletag.defineSlot('/112115922/FL_PB_MedRect', [[300,250]], 'test-div2').addService(googletag.pubads());
googletag.pubads().enableSingleRequest();
googletag.enableServices();
});
</script>
</head>

<body>
<img src="prebid-trigger.gif" />
<header>
<h1>Safari 3rd party set cookie workaround</h1>
<nav>
<a href="pages/page-one.html">site sub-page #1</a>
<a href="pages/page-two.html">site sub-page #2</a>
</nav>
<h2>Rubicon Project Prebid Server Demo</h2>
</header>
<p>The ad units below were retrieved from Rubicon Project's cluster of Prebid Servers.</p>
<div id='test-div'>
<script>
googletag.cmd.push(function() { googletag.display('test-div'); });
</script>
</div>
<div id='test-div2'>
<script>
googletag.cmd.push(function() { googletag.display('test-div2'); });
</script>
</div>
</body>
</html>

5 changes: 2 additions & 3 deletions modules/prebidServerBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import { VIDEO } from 'src/mediaTypes';
const getConfig = config.getConfig;

const TYPE = S2S.SRC;
const cookieSetUrl = 'https://acdn.adnxs.com/cookieset/cs.js';
let _synced = false;

/**
Expand Down Expand Up @@ -254,9 +253,9 @@ function PrebidServer() {
});
});
}
if (result.status === 'no_cookie' && config.cookieSet) {
if (result.status === 'no_cookie' && config.cookieSet && config.cookieSetUrl) {
// cookie sync
cookieSet(cookieSetUrl);
cookieSet(config.cookieSetUrl);
}
} catch (error) {
utils.logError(error);
Expand Down
3 changes: 2 additions & 1 deletion src/constants.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@
"SRC" : "s2s",
"ADAPTER" : "prebidServer",
"SYNC_ENDPOINT" : "https://prebid.adnxs.com/pbs/v1/cookie_sync",
"SYNCED_BIDDERS_KEY": "pbjsSyncs"
"SYNCED_BIDDERS_KEY": "pbjsSyncs",
"COOKIE_SET_URL": "https://acdn.adnxs.com/cookieset/cs.js"
}
}
2 changes: 2 additions & 0 deletions src/prebid.js
Original file line number Diff line number Diff line change
Expand Up @@ -806,6 +806,7 @@ $$PREBID_GLOBAL$$.getHighestCpmBids = function (adUnitCode) {
* @property {string} [adapter] adapter code to use for S2S
* @property {string} [syncEndpoint] endpoint URL for syncing cookies
* @property {boolean} [cookieSet] enables cookieSet functionality
* @property {string} [cookieSetUrl] override the default cookieSet endpoint
* @alias module:pbjs.setS2SConfig
*/
$$PREBID_GLOBAL$$.setS2SConfig = function(options) {
Expand All @@ -827,6 +828,7 @@ $$PREBID_GLOBAL$$.setS2SConfig = function(options) {
adapter: CONSTANTS.S2S.ADAPTER,
syncEndpoint: CONSTANTS.S2S.SYNC_ENDPOINT,
cookieSet: true,
cookieSetUrl: CONSTANTS.S2S.COOKIE_SET_URL,
bidders: []
}, options);
adaptermanager.setS2SConfig(config);
Expand Down