| layout | example | ||
|---|---|---|---|
| title | Individual Ad Unit Refresh / Infinite Scroll | ||
| description | Individual Ad Unit Refresh / Infinite Scroll | ||
| sidebarType | 1 | ||
| about |
|
||
| pid | 20 |
{% capture htmlCodePrebid %}
Refresh Ad Unit{% capture jsCode %}var sizes = [ [300, 250] ]; var PREBID_TIMEOUT = 1000;
var googletag = googletag || {}; googletag.cmd = googletag.cmd || [];
var pbjs = pbjs || {}; pbjs.que = pbjs.que || [];
var adUnits = [{ code: '/19968336/header-bid-tag-0', mediaTypes: { banner: { sizes: sizes } }, bids: [{ bidder: 'appnexus', params: { placementId: 13144370 } }] }];
pbjs.que.push(function() { pbjs.addAdUnits(adUnits); });
var slot1; googletag.cmd.push(function() { slot1 = googletag.defineSlot('/19968336/header-bid-tag-0', [[300, 250]], 'div-1') .addService(googletag.pubads()); googletag.pubads().disableInitialLoad(); googletag.pubads().enableSingleRequest(); googletag.enableServices(); });
function refreshBid() { pbjs.que.push(function() { pbjs.requestBids({ timeout: PREBID_TIMEOUT, adUnitCodes: ['/19968336/header-bid-tag-0'], bidsBackHandler: function() { pbjs.setTargetingForGPTAsync(['/19968336/header-bid-tag-0']); googletag.pubads().refresh([slot1]); } }); }); } {% endcapture %}
{% include code/web-example.html id="basic-prebid-example" html=htmlCodePrebid js=jsCode %}