| layout | example | |||
|---|---|---|---|---|
| title | Native Ad Unit | |||
| description | Native Ad Units | |||
| sidebarType | 1 | |||
| about |
|
{% capture htmlCodePrebid %}
No response
<script type='text/javascript'> googletag.cmd.push(function() { googletag.display('div-1'); }); </script>No response
<script type='text/javascript'> googletag.cmd.push(function() { googletag.display('div-2'); }); </script>{% capture jsCode %} var googletag = googletag || {}; googletag.cmd = googletag.cmd || [];
var pbjs = pbjs || {}; pbjs.que = pbjs.que || []; var PREBID_TIMEOUT = 3000;
var date = new Date().getTime();
function initAdserver() { if (pbjs.initAdserverSet) return;
googletag.cmd.push(function() {
if (pbjs.libLoaded) {
pbjs.que.push(function() {
pbjs.setTargetingForGPTAsync();
googletag.pubads().refresh();
});
} else {
googletag.pubads().refresh();
}
});
pbjs.initAdserverSet = true;
}
// Load GPT when timeout is reached. setTimeout(initAdserver, PREBID_TIMEOUT);
pbjs.que.push(function() {
pbjs.setConfig({
debug: true
});
var allSlotsBidWon = function allSlotsBidWon() {
console.log('allSlotsBidWon called');
};
pbjs.onEvent('bidWon', allSlotsBidWon);
var adUnits = [{
code: '/19968336/prebid_native_example_1',
sizes: [
[360, 360]
],
mediaTypes: {
native: {
title: {
required: true
},
image: {
required: true
},
sponsoredBy: {
required: true
}
}
},
bids: [{
bidder: 'appnexus',
params: {
placementId: 13232354,
allowSmallerSizes: true
}
}]
},
{
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
}
}]
}
];
pbjs.addAdUnits(adUnits);
pbjs.requestBids({
bidsBackHandler: function(bidResponses) {
initAdserver();
}
});
});
// GPT setup googletag.cmd.push(function() { var slot1 = googletag.defineSlot('/19968336/prebid_native_example_1', [[360, 360]], 'div-1').addService(googletag.pubads()); var slot2 = googletag.defineSlot('/19968336/prebid_native_example_2', 'fluid', 'div-2').addService(googletag.pubads()); googletag.pubads().disableInitialLoad(); googletag.pubads().enableSingleRequest(); googletag.enableServices(); });
{% endcapture %}
{% include code/web-example.html id="basic-prebid-example" html=htmlCodePrebid js=jsCode %}