-
Notifications
You must be signed in to change notification settings - Fork 2.1k
/
Copy pathprecisonativeExample.html
203 lines (189 loc) · 7.75 KB
/
precisonativeExample.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
<html>
<head>
<script type="text/javascript" src="../../build/dev/prebid.js" async></script>
<script>
var PREBID_TIMEOUT = 2000;
var adUnits = [
{
code: 'test-div',
mediaTypes: {
native: {
adTemplate: `
<div class="sponsored-post">
<div class="thumbnail" style="background-image: url('${encodeURI('##hb_native_asset_id_2##')}'); width=100%; height=100%; background-repeat: no-repeat;
background-size: cover; >
<div class="content">
<h1>
<a href="${encodeURI("https://" + '##hb_native_linkurl##')}" target="_blank" class="pb-click" hb_native_asset_id="4" >
${encodeURI('##hb_native_body##')}
</a>
</h1>
<p class="pb-click">${encodeURI('##hb_native_asset_id_4##')}</p>
<div class="attribution" class="pb-click hb_native_asset_id="1">${encodeURI('##hb_native_asset_id_1##')}</div>
</div>
</div>
</div>
`,
ortb: {
assets: [
{
id: 2,
required: 0,
img: {
type: 3,
w: 300,
h: 250
}
},
{
id: 1,
required: 1,
title: {
len: 800
}
},
{
id: 4,
required: 0,
data: {
type: 1
}
}
]
}
}
},
bids: [
{
bidder: 'preciso',
params: {
publisherId: 'PRECISO_TEST00001',
traffic: 'native',
// bidFloor: 0.12,
// currency: ['USD']
}
}
]
}
];
var pbjs = pbjs || {};
pbjs.que = pbjs.que || [];
</script>
<script>
pbjs.que.push(function () {
pbjs.setConfig({ enableSendAllBids: true });
pbjs.addAdUnits(adUnits);
pbjs.setConfig({
userSync: {
userIds: [{
name: 'sharedId',
storage: {
name: '_sharedid',
type: 'cookie',
expires: 365
}
}],
filterSettings: {
iframe: {
bidders: ['preciso'],
filter: 'include'
},
image: {
bidders: ['preciso'],
filter: 'include'
}
}
},
floors: {
currency: 'USD',
skipRate: 5,
modelVersion: 'Sports Ad Unit Floors',
schema: {
fields: ['mediaType']
},
values: {
'banner': 0.05,
'native': 0.1
}
},
ortb2: {
bcat: ['IAB1-1'],
badv: ['example.com'],
wlang: ['fr', 'en']
},
enableTIDs: true,
debug: true
});
});
function renderEverything() {
var winners = pbjs.getHighestCpmBids();
for (var i = 0; i < winners.length; i++) {
renderOne(winners[i]);
}
}
function renderOne(winningBid) {
if (winningBid && winningBid.adId) {
let options = winningBid.adm
console.log("Here 123");
var div = document.getElementById(winningBid.adUnitCode);
if (div) {
let iframe = document.createElement('iframe');
iframe.frameBorder = '0';
iframe.style.width = '300';
iframe.style.height = '600';
div.appendChild(iframe);
console.log("Here 1234");
if (winningBid.mediaType == "native") {
console.log("Here 1234 native");
var domdoc = iframe.contentWindow.document;
console.log("Here 12345 native");
pbjs.renderAd(domdoc, winningBid.adId);
console.log("Here 123456 native");
}
}
}
}
</script>
<script>
pbjs.que.push(function () {
pbjs.requestBids({
timeout: 2000,
bidsBackHandler: renderEverything
});
});
</script>
<script src="https://cdn.jsdelivr.net/npm/prebid-universal-creative@latest/dist/native.js"></script>
<script>
var pbNativeTagData = {};
pbNativeTagData.pubUrl = '##hb_adomain##'; // GAM specific
pbNativeTagData.adId = "##hb_adid##"; // GAM specific
// if you're using 'Send All Bids' mode, you should use %%PATTERN:hb_adid_BIDDER%%
pbNativeTagData.requestAllAssets = true;
// if you want to track clicks in GAM, add the following variable
pbNativeTagData.clickUrlUnesc = "%%CLICK_URL_UNESC%%";
window.pbNativeTag.renderNativeAd(pbNativeTagData);
</script>
</head>
<body>
<h2>Ad Serverless Test Page</h2>
<p>
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's
standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make
a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting,
remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing
Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions
of Lorem Ipsum
</p>
<div id="test-div"></div>
<p>
Contrary to popular belief, Lorem Ipsum is not simply random text. It has roots in a piece of classical Latin
literature from 45 BC, making it over 2000 years old. Richard McClintock, a Latin professor at Hampden-Sydney
College in Virginia, looked up one of the more obscure Latin words, consectetur, from a Lorem Ipsum passage, and
going through the cites of the word in classical literature, discovered the undoubtable source. Lorem Ipsum
comes from sections 1.10.32 and 1.10.33 of "de Finibus Bonorum et Malorum" (The Extremes of Good and Evil) by
Cicero, written in 45 BC. This book is a treatise on the theory of ethics, very popular during the Renaissance.
The first line of Lorem Ipsum, "Lorem ipsum dolor sit amet..", comes from a line in section 1.10.32.
</p>
<div id="test-nat-div"></div>
</body>
</html>