Skip to content

Commit

Permalink
update AFP Adapter and add page examples
Browse files Browse the repository at this point in the history
  • Loading branch information
andrey-ka-97 committed Aug 13, 2021
1 parent a9c97e6 commit 6e15c6a
Show file tree
Hide file tree
Showing 8 changed files with 954 additions and 551 deletions.
115 changes: 115 additions & 0 deletions integrationExamples/gpt/afpExample.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Prebid.js Banner Example</title>
<script src="../../../build/dev/prebid.js"></script>
<script>
var adUnits = [{
code: 'iib-target',
mediaTypes: {
banner: {
sizes: [0, 0],
}
},
bids: [{
bidder: "afp",
params: {
placeType: "In-image",
placeId: "60e7039918047b3fae304850",
placeContainer: '#iib-container',
imageUrl: "https://rtbinsight.ru/content/images/size/w1000/2021/05/ximage-30.png.pagespeed.ic.IfuX4zAEPP.png",
imageWidth: 1000,
imageHeight: 524,
}
}]
},
{
code: 'icv-target',
mediaTypes: {
video: {
playerSize: [640, 480]
}
},
bids: [{
bidder: "afp",
params: {
placeType: "In-content Video",
placeId: "60e5684718047b3fae304617",
placeContainer: '#icv-container',
}
}]
},
{
code: 'asb-target',
mediaTypes: {
banner: {
sizes: [500, 500],
}
},
bids: [{
bidder: "afp",
params: {
placeType: "Action Scroller",
placeId: "60f15a8515770d5ab7c7f885",
placeContainer: '#asb-container',
}
}]
}];

var pbjs = pbjs || {};
pbjs.que = pbjs.que || [];

pbjs.que.push(function() {
pbjs.addAdUnits(adUnits);
pbjs.requestBids({
bidsBackHandler: function (e) {
if (pbjs.adserverRequestSent) return;
pbjs.adserverRequestSent = true;
var params = pbjs.getAdserverTargetingForAdUnitCode("iib-target");
var iframe = document.getElementById("iib-target");

if (params && params['hb_adid']) {
pbjs.renderAd(iframe.contentDocument, params['hb_adid']);
}

params = pbjs.getAdserverTargetingForAdUnitCode("icv-target");
iframe = document.getElementById("icv-target");

if (params && params['hb_adid']) {
pbjs.renderAd(iframe.contentDocument, params['hb_adid']);
}

params = pbjs.getAdserverTargetingForAdUnitCode("asb-target");
iframe = document.getElementById("asb-target");

if (params && params['hb_adid']) {
pbjs.renderAd(iframe.contentDocument, params['hb_adid']);
}
}
});
});
</script>
</head>
<body>
<h2>In-image</h2>
<div class="container-wrapper">
<div id="iib-container" style="width: 600px;">
<img src="https://creative.astraone.io/files/default_image-1-600x400.jpg" width="100%" />
</div>
<iframe id="iib-target" style="display: none;"></iframe>
</div>

<h2>In-content Video</h2>
<div class="container-wrapper">
<div id="icv-container"></div>
<iframe id="icv-target" style="display: none;"></iframe>
</div>

<h2>Action Scroller</h2>
<div class="container-wrapper">
<div id="asb-container"></div>
<iframe id="asb-target" style="display: none;"></iframe>
</div>
</body>
</html>
152 changes: 152 additions & 0 deletions integrationExamples/gpt/afpGamExample.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,152 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Prebid.js Banner Example</title>
<script async src="https://www.googletagservices.com/tag/js/gpt.js"></script>
<script src="../../../build/dev/prebid.js"></script>
<script>
var adUnits = [{
code: 'div-gpt-ad-1574864639578-0',
mediaTypes: {
banner: {
sizes: [0, 0],
}
},
bids: [{
bidder: "afp",
params: {
placeType: "In-image",
placeId: "60e7039918047b3fae304850",
placeContainer: '#iib-container',
imageUrl: "https://rtbinsight.ru/content/images/size/w1000/2021/05/ximage-30.png.pagespeed.ic.IfuX4zAEPP.png",
imageWidth: 600,
imageHeight: 400,
}
}]
},
{
code: 'div-gpt-ad-1574864639578-1',
mediaTypes: {
video: {
playerSize: [640, 480]
}
},
bids: [{
bidder: "afp",
params: {
placeType: "In-content Video",
placeId: "60e5684718047b3fae304617",
placeContainer: '#icv-container',
}
}]
},
{
code: 'div-gpt-ad-1574864639578-2',
mediaTypes: {
banner: {
sizes: [500, 500],
}
},
bids: [{
bidder: "afp",
params: {
placeType: "Action Scroller",
placeId: "60f15a8515770d5ab7c7f885",
placeContainer: '#asb-container',
}
}]
}];

var pbjs = pbjs || {};
pbjs.que = pbjs.que || [];

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

googletag.cmd.push(() => {
googletag.pubads().disableInitialLoad();
});

pbjs.que.push(() => {
pbjs.addAdUnits(adUnits);
pbjs.requestBids({ bidsBackHandler: sendAdServerRequest });
});

function sendAdServerRequest() {
googletag.cmd.push(() => {
pbjs.que.push(() => {
pbjs.setTargetingForGPTAsync('div-gpt-ad-1574864639578-0');
pbjs.setTargetingForGPTAsync('div-gpt-ad-1574864639578-1');
pbjs.setTargetingForGPTAsync('div-gpt-ad-1574864639578-2');
googletag.pubads().refresh();
});
});
}

googletag.cmd.push(() => {
googletag
.defineSlot('/19968336/header-bid-tag-0', [300, 250], 'div-gpt-ad-1574864639578-0')
.addService(googletag.pubads());
googletag.pubads().enableSingleRequest();
googletag.enableServices();
});

googletag.cmd.push(() => {
googletag
.defineSlot('/19968336/header-bid-tag-0', [300, 250], 'div-gpt-ad-1574864639578-1')
.addService(googletag.pubads());
googletag.pubads().enableSingleRequest();
googletag.enableServices();
});

googletag.cmd.push(() => {
googletag
.defineSlot('/19968336/header-bid-tag-0', [300, 250], 'div-gpt-ad-1574864639578-2')
.addService(googletag.pubads());
googletag.pubads().enableSingleRequest();
googletag.enableServices();
});

</script>
</head>
<body id="ocv-container">
<h2>In-image</h2>
<div class="container-wrapper">
<div id="iib-container" style="width: 600px;">
<img src="https://creative.astraone.io/files/default_image-1-600x400.jpg" width="100%" />
</div>
<div id="div-gpt-ad-1574864639578-0">
<script type="text/javascript">
googletag.cmd.push(function() {
googletag.display('div-gpt-ad-1574864639578-0');
});
</script>
</div>
</div>

<h2>In-content Video</h2>
<div class="container-wrapper">
<div id="icv-container"></div>
<div id="div-gpt-ad-1574864639578-1">
<script type="text/javascript">
googletag.cmd.push(function() {
googletag.display('div-gpt-ad-1574864639578-1');
});
</script>
</div>
</div>

<h2>Action Scroller</h2>
<div class="container-wrapper">
<div id="asb-container"></div>
<div id="div-gpt-ad-1574864639578-2">
<script type="text/javascript">
googletag.cmd.push(function() {
googletag.display('div-gpt-ad-1574864639578-2');
});
</script>
</div>
</div>
</body>
</html>
Loading

0 comments on commit 6e15c6a

Please sign in to comment.