Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- window.track = function (action, adId) {
- var message = {message: 'Prebid Native', adId: adId};
- if (action === 'click') { message.action = 'click'; }
- window.parent.postMessage(JSON.stringify(message), '*');
- }
- var render = function(bid, adUnitDivId) {
- // Can include CSS styles here, or just use styles from your site.
- var markup = `
- <style>
- .native-ad {
- background-color: #fff;
- border: 1px solid #EDEDED;
- border-radius: 4px;
- overflow: hidden;
- font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
- font-size: 12px;
- height: 248px;
- width: 298px;
- position: relative;
- }
- .inset-box {
- border-radius: 2px;
- background-color: #fff;
- position: absolute;
- padding: 2px 5px;
- }
- .inset-box-text {
- display: block;
- height: 15px;
- font-size: 12px;
- line-height: 14px;
- text-align: center;
- color: #333333;
- text-decoration: none;
- }
- .attribution {
- left: 10px;
- top: 10px;
- }
- .image img {
- height: 158px;
- width: 298px;
- border-radius: 4px 4px 0 0;
- object-fit: cover;
- }
- .advertiser {
- width: 96px;
- right: 10px;
- top: 10px;
- }
- .title {
- height: 24px;
- text-align: center;
- margin-top: 10px;
- margin-bottom: 10px;
- }
- .title a {
- color: #000000;
- font-size: 20px;
- font-weight: bold;
- line-height: 25px;
- text-decoration: none;
- }
- .call-to-action {
- display: block;
- width: 77px;
- border-radius: 4px;
- background-color: #3E86C7;
- margin: 0 auto;
- padding: 8px 15.5px;
- text-align: center;
- text-decoration: none;
- }
- .call-to-action-text {
- height: 18px;
- color: #FFFFFF;
- font-size: 14px;
- font-weight: bold;
- line-height: 17px;
- }
- </style>
- <div class='native-ad'>
- <div class='attribution inset-box'>
- <span class='inset-box-text'>Ad</span>
- </div>
- <div class='image'>
- <a href='${bid.native.clickUrl}' target='_blank' onclick="window.track('click', '${bid.adId}');"><img src='${bid.native.image.url}'></a>
- </div>
- <div class='advertiser inset-box'>
- <a id='native-brand' class='inset-box-text' href='${bid.native.clickUrl}' target='_blank' onclick="window.track('click', '${bid.adId}');">${bid.native.sponsoredBy}</a>
- </div>
- <div class='title'>
- <a id='native-title' href='${bid.native.clickUrl}' target='_blank' onclick="window.track('click', '${bid.adId}');">${bid.native.title}</a>
- </div>
- <a class='call-to-action' href='${bid.native.clickUrl}' target='_blank' onclick="window.track('click', '${bid.adId}');">
- <span class='call-to-action-text'>Learn More</span>
- </a>
- </div>`
- // Insert ad into document.
- var container = document.createElement("div");
- container.innerHTML = markup;
- document.getElementById(adUnitDivId).appendChild(container);
- window.track('impression', bid.adId);
- };
- window.NativeRenderer = render
Add Comment
Please, Sign In to add comment