Skip to content

AdBund/Header-Bidding-Example

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 

Repository files navigation

Header-Bidding-Example

  
<!doctype html>
<html>
	<head>
		<title>PrebidJS Test</title>
		<meta charset="utf-8">
		<!-- Prebid Config Section START -->
		<!-- Make sure this is inserted before your GPT tag -->
		<script>
			var PREBID_TIMEOUT = 700;

			var adUnits = [{
				code: 'div-gpt-ad-1460505748561-0',
				sizes: [[300, 250]],
				bids: [
					{
						bidder: 'adbund',
						params: {
							sid: '110238',//please change it to your sid,get this code from:http://www.adbund.com
							bidfloor: 0.036
						}
					},
					{
						bidder: 'sovrn',
						params: {
							tagid: '405749',
							size: [300, 250]
						}
					}
				]
			}];

			var pbjs = pbjs || {};
			pbjs.que = pbjs.que || [];
		</script>
		<!-- Prebid Config Section END -->

		<!-- Prebid Boilerplate Section START. No Need to Edit. -->
		<script type="text/javascript" src="prebid.js" async></script>
		<script>
			var googletag = googletag || {};
			googletag.cmd = googletag.cmd || [];
			googletag.cmd.push(function() {
				googletag.pubads().disableInitialLoad();
			});

			pbjs.que.push(function() {
				//console.log('que.push-units:');
				//console.log(JSON.stringify(adUnits, null, 4));
				pbjs.addAdUnits(adUnits);
				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>
		<!-- Prebid Boilerplate Section END -->

		<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('/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>
  

About

AdBund header bidding example

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published