Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adspirit Bid Adapter: initial release #10939

Merged
merged 14 commits into from
Feb 28, 2024
137 changes: 137 additions & 0 deletions modules/adspiritBidAdapter.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,137 @@
import * as utils from '../src/utils.js';
import { registerBidder } from '../src/adapters/bidderFactory.js';
import { BANNER, NATIVE } from '../src/mediaTypes.js';

const RTB_URL = '/rtb/getbid.php?rtbprovider=prebid';
const SCRIPT_URL = '/adasync.min.js';

export const spec = {

code: 'adspirit',
aliases: ['twiago'],
supportedMediaTypes: [BANNER, NATIVE],

isBidRequestValid: function (bid) {
let host = spec.getBidderHost(bid);
if (!host || !bid.params.placementId) {
return false;
}
return true;
},

buildRequests: function (validBidRequests, bidderRequest) {
let requests = [];
for (let i = 0; i < validBidRequests.length; i++) {
let bidRequest = validBidRequests[i];
bidRequest.adspiritConId = spec.genAdConId(bidRequest);
let reqUrl = spec.getBidderHost(bidRequest);
let placementId = utils.getBidIdParameter('placementId', bidRequest.params);
reqUrl = '//' + reqUrl + RTB_URL + '&pid=' + placementId +
'&ref=' + encodeURIComponent(bidderRequest.refererInfo.topmostLocation) +
'&scx=' + (screen.width) +
'&scy=' + (screen.height) +
'&wcx=' + (window.innerWidth || document.documentElement.clientWidth) +
'&wcy=' + (window.innerHeight || document.documentElement.clientHeight) +
'&async=' + bidRequest.adspiritConId +
'&t=' + Math.round(Math.random() * 100000);

let data = {};

if (bidderRequest && bidderRequest.gdprConsent) {
const gdprConsentString = bidderRequest.gdprConsent.consentString;
reqUrl += '&gdpr=' + encodeURIComponent(gdprConsentString);
}

if (bidRequest.schain && bidderRequest.schain) {
data.schain = bidRequest.schain;
}

requests.push({
method: 'GET',
url: reqUrl,
data: data,
bidRequest: bidRequest
});
}
return requests;
},

interpretResponse: function (serverResponse, bidRequest) {
const bidResponses = [];
let bidObj = bidRequest.bidRequest;

if (!serverResponse || !serverResponse.body || !bidObj) {
utils.logWarn(`No valid bids from ${spec.code} bidder!`);
return [];
}

let adData = serverResponse.body;
let cpm = adData.cpm;

if (!cpm) {
return [];
}

let host = spec.getBidderHost(bidObj);
let bidResponse;
if ('mediaTypes' in bidObj && 'native' in bidObj.mediaTypes) {
bidResponse = {
requestId: bidObj.bidId,
cpm: cpm,
width: adData.w,
height: adData.h,
creativeId: bidObj.params.placementId,
currency: 'EUR',
netRevenue: true,
ttl: 300,
meta: {
advertiserDomains: bidObj && bidObj.adomain ? bidObj.adomain : []
},
native: {
title: adData.title,
body: adData.body,
cta: adData.cta,
image: { url: adData.image },
clickUrl: adData.click,
impressionTrackers: [adData.view]
},
mediaType: NATIVE
};
} else {
let adm = '<script>window.inDapIF=false</script><script src="//' + host + SCRIPT_URL + '"></script><ins id="' + bidObj.adspiritConId + '"></ins>' + adData.adm;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

whats the difference if the server responds with a script or if the code creates the script?

bidResponse = {
requestId: bidObj.bidId,
cpm: cpm,
width: adData.w,
height: adData.h,
creativeId: bidObj.params.placementId,
currency: 'EUR',
netRevenue: true,
ttl: 300,
meta: {
advertiserDomains: bidObj && bidObj.adomain ? bidObj.adomain : []
},
ad: adm,
mediaType: BANNER
};
}
mmoschovas marked this conversation as resolved.
Show resolved Hide resolved
bidResponses.push(bidResponse);
return bidResponses;
},

getBidderHost: function (bid) {
if (bid.bidder === 'adspirit') {
return utils.getBidIdParameter('host', bid.params);
}
if (bid.bidder === 'twiago') {
return 'a.twiago.com';
}
return null;
},

genAdConId: function (bid) {
return bid.bidder + Math.round(Math.random() * 100000);
}
};

registerBidder(spec);
68 changes: 68 additions & 0 deletions modules/adspiritBidAdapter.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
# Overview

```
Module Name: Adspirit Bid Adapter
Module Type: Bidder Adapter
Maintainer: prebid@adspirit.de

```
# Description

Connects to Adspirit exchange for bids.

Each adunit with `adspirit` adapter has to have `placementId` and `host`.


### Supported Features;

1. Media Types: Banner & native
2. Multi-format: adUnits
3. Schain module
4. Advertiser domains


## Sample Banner Ad Unit
```javascript
var adUnits = [
{
code: 'display-div',

mediaTypes: {
banner: {
sizes: [[300, 250]] //a display size
}
},

bids: [
{
bidder: "adspirit",
params: {
placementId: '7', //Please enter your placementID
host: 'test.adspirit.de' //your host details from Adspirit
}
}
]
}
];

```


### Privacy Policies

General Data Protection Regulation(GDPR) supported by default.

Complete informationavilable on this url-- https://support.adspirit.de/hc/en-us/categories/115000453312-General


### CMP (Consent Management Provider)
CMP stands for Consent Management Provider. In simple terms, this is a service provider that obtains and processes the consent of the user, makes it available to the advertisers and, if necessary, logs it for later control. We recommend using a provider with IAB certification or CMP based on the IAB CMP Framework. A list of IAB CMPs can be found at https://iabeurope.eu/cmp-list/. AdSpirit recommends the use of
www.consentmanager.de .

### List of functions that require consent

Please visit our page- https://support.adspirit.de/hc/en-us/articles/360014631659-List-of-functions-that-require-consent




Loading