[ prebid ] GPT prebid configuration refresh example

var PREBID_TIMEOUT = 1000;

var googletag = googletag || {};
googletag.cmd = googletag.cmd || [];

function initAdserver() {
if (pbjs.initAdserverSet) return;
(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);
})();
pbjs.initAdserverSet = true;
};
setTimeout(initAdserver, PREBID_TIMEOUT);

var pbjs = pbjs || {};
pbjs.que = pbjs.que || [];
(function() {
var pbjsEl = document.createElement("script");
pbjsEl.type = "text/javascript";
pbjsEl.async = true;
pbjsEl.src = "//acdn.adnxs.com/prebid/not-for-prod/prebid.js";
var pbjsTargetEl = document.getElementsByTagName("head")[0];
pbjsTargetEl.insertBefore(pbjsEl, pbjsTargetEl.firstChild);
})();

pbjs.que.push(function() {
// request ads
var adUnits = [{
code: 'div-gpt-ad-1438287399331-0',
sizes: [[300, 250], [300, 600]],
bids: [{
bidder: 'appnexus',
params: { placementId: '10433394' }
}, {
bidder: 'pubmatic',
params: {
publisherId: 'TO ADD',
adSlot: 'TO ADD'
}
}]
},{
code: 'div-gpt-ad-1438287399331-1',
sizes: [[728, 90], [970, 90]],
bids: [{
bidder: 'appnexus',
params: { placementId: '10433394' }
}]
}];
pbjs.addAdUnits(adUnits); // NOTE : adUnits is an array

pbjs.requestBids({
bidsBackHandler: function(bidResponses) {
initAdserver();
}
})
});

/////////////////////////////////////////////////////////////////////////
var rightSlot;
var topSlot;

// define ads
googletag.cmd.push(function() {
rightSlot = googletag.defineSlot('/19968336/header-bid-tag-0', [[300, 250], [300, 600]], 'div-gpt-ad-1438287399331-0').addService(googletag.pubads());

topSlot = googletag.defineSlot('/19968336/header-bid-tag1', [[728, 90], [970, 90]], 'div-gpt-ad-1438287399331-1').addService(googletag.pubads());

pbjs.que.push(function() {
pbjs.setTargetingForGPTAsync();
});

googletag.pubads().enableSingleRequest();
googletag.enableServices();
});

// refresh ads

function refreshBid1() {
pbjs.que.push(function() {
pbjs.requestBids({
timeout: PREBID_TIMEOUT,
adUnitCodes: ['div-gpt-ad-1438287399331-0'],
bidsBackHandler: function() {
pbjs.setTargetingForGPTAsync(['div-gpt-ad-1438287399331-0']);
googletag.pubads().refresh([rightSlot]);
}
});
});
}

function refreshBid2() {
pbjs.que.push(function() {
pbjs.requestBids({
timeout: PREBID_TIMEOUT,
adUnitCodes: ['div-gpt-ad-1438287399331-1'],
bidsBackHandler: function() {
pbjs.setTargetingForGPTAsync(['div-gpt-ad-1438287399331-1']);
googletag.pubads().refresh([topSlot]);
}
});
});
}

function refreshAllBid() {
pbjs.que.push(function() {
pbjs.requestBids({
timeout: PREBID_TIMEOUT,
bidsBackHandler: function() {
pbjs.setTargetingForGPTAsync();
googletag.pubads().refresh([topSlot]);
}
});
});
}

 

ref : http://prebid.org/dev-docs/examples/adunit-refresh.html ,

http://prebid.org/dev-docs/publisher-api-reference.html#module_pbjs.requestBids ,

http://prebid.org/dev-docs/publisher-api-reference.html#module_pbjs.setTargetingForGPTAsync

 

header bidding partners

bidder in the refresh section

What is bidding parter ?

https://support.google.com/dfp_premium/answer/7128958?hl=en

What is placement id ?

See example parameter in AppNenus bidder

http://prebid.org/dev-docs/bidders.html

Support bidding partners

  • Appnexus
  • AppnexusAst (Beta)
  • Openx
  • Pubmatic
  • Rubicon
  • Yieldbot
  • Aol
  • IndexExchange
  • Sovrn
  • Pulsepoint
  • Triplelift
  • Springserve
  • Adform
  • Nginad
  • Brightcom
  • Adequant
  • Sonobi
  • Aardvark
  • Wideorbit
  • Kruxlink
  • Admedia
  • Jcm ( J Carter Marketing )
  • Memeglobal
  • Underdogmedia
  • Brealtime
  • Pagescience
  • Centro
  • Adblade
  • Piximedia
  • Getintent
  • Defymedia
  • Hiromedia
  • Roxot
  • Adbutler
  • Komoona
  • Rhythmone
  • Vertoz
  • Adkernel
  • Conversant Media
  • Featureforward
  • DistrictmDMX
  • Gumgum
  • Fidelity Media
  • Widespace
  • SekindoUM ( Sekindo Universal Mccann )
  • Smartadserver
  • Headbidding
  • Sharethrough
  • Smartyads
  • Twenga
  • Xhb ( Xaxis )
  • Lifestreet
  • Mantis ( Mantis Ad Network )
  • Admixer
  • Vertamedia
  • Oftmedia ( 152Media )
  • Matomy
  • Stickyadstv
  • Thoughtleadr
  • Adbund
  • Tapsense
  • Serverbid
  • Bidfluence
  • PulsepointLite
  • AudienceNetwork ( Facebook Audience Network )
  • Atomx
  • Inneractive
  • Gourmetads
  • Freewheel-ssp
  • Innity
  • Beachfront Media
  • Trion Interactive
  • Huddledmasses
  • Pubgears
  • Adsupply
  • Quantcast
  • PrebidServer
  • Carambola
  • Cox
  • Eplanning
  • Unruly

 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s