mk9-prebid
Version:
Header Bidding Management Library
144 lines (131 loc) • 3.33 kB
HTML
<html>
<head>
<script async src="../../build/dist/prebid.js"></script>
<script async src="https://www.googletagservices.com/tag/js/gpt.js"></script>
<script>
var PREBID_TIMEOUT = 5000;
var adUnits = [{
code: 'div-gpt-ad-1460505748561-0',
mediaTypes: {
banner: {
sizes: [[300, 250], [300, 600]],
}
},
// Replace this object to test a new Adapter!
bids: [{
bidder: 'appnexus',
params: {
placementId: 13144370
}
}]
}, {
code: '/19968336/prebid_native_example_2',
sizes: [
[1, 1]
],
mediaTypes: {
native: {
title: {
required: true
},
body: {
required: true
},
image: {
required: true
},
sponsoredBy: {
required: true
},
icon: {
required: false
},
}
},
bids: [{
bidder: 'appnexus',
params: {
placementId: 13232354,
allowSmallerSizes: true
}
}]
}];
var pbjs = pbjs || {};
pbjs.que = pbjs.que || [];
</script>
<script>
var googletag = googletag || {};
googletag.cmd = googletag.cmd || [];
googletag.cmd.push(function () {
googletag.pubads().disableInitialLoad();
});
pbjs.que.push(function () {
pbjs.addAdUnits(adUnits);
pbjs.setConfig({
sizeConfig: [{
'mediaQuery': '(min-width: 1600px)',
'sizesSupported': [
[300, 600],
[970, 90],
[728, 90],
[300, 250]
],
'labels': ['desktop-hd']
}, {
'mediaQuery': '(min-width: 1200px)',
'sizesSupported': [
[300, 600],
[728, 90],
[300, 250]
],
'labels': ['desktop']
}, {
'mediaQuery': '(min-width: 768px) and (max-width: 1199px)',
'sizesSupported': [
[300, 600],
[300, 250]
],
'labels': ['tablet']
}, {
'mediaQuery': '(min-width: 0px)',
'sizesSupported': [
[300, 250],
[300, 600]
],
'labels': ['phone']
}]
});
pbjs.requestBids({
bidsBackHandler: sendAdserverRequest,
timeout: PREBID_TIMEOUT
});
});
function sendAdserverRequest() {
if (pbjs.adserverRequestSent) return;
pbjs.adserverRequestSent = true;
googletag.cmd.push(function () {
pbjs.que.push(function () {
pbjs.setTargetingForGPTAsync();
googletag.pubads().refresh();
});
});
}
</script>
<script>
googletag.cmd.push(function () {
googletag.defineSlot('/19968336/header-bid-tag-0', [[300, 250], [300, 600]], 'div-gpt-ad-1460505748561-0').addService(googletag.pubads());
googletag.pubads().enableSingleRequest();
googletag.enableServices();
});
</script>
</head>
<body>
<h2>Prebid.js Test</h2>
<h5>Div-1</h5>
<div id='div-gpt-ad-1460505748561-0'>
<script type='text/javascript'>
googletag.cmd.push(function () { googletag.display('div-gpt-ad-1460505748561-0'); });
</script>
</div>
</body>
</html>