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

eTarget Bid Adapter: add "getMetaData" function to adapter, support for advertiserDomains #6901

Merged
merged 6 commits into from
Jun 1, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 37 additions & 2 deletions modules/etargetBidAdapter.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
'use strict';

import * as utils from '../src/utils.js';
import {config} from '../src/config.js';
import {registerBidder} from '../src/adapters/bidderFactory.js';
import { BANNER, VIDEO } from '../src/mediaTypes.js';

Expand Down Expand Up @@ -57,10 +57,40 @@ export const spec = {
data: bidderRequest,
bids: validBidRequests,
netRevenue: netRevenue,
metaData: getMetaData(),
bidder: 'etarget',
gdpr: gdprObject
};

function getMetaData() {
var mts = {};
var hmetas = document.getElementsByTagName('meta');
var wnames = ['title', 'og:title', 'description', 'og:description', 'og:url', 'base', 'keywords'];
Copy link
Collaborator

Choose a reason for hiding this comment

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

Publishers may want to pass this information to all partners via the ortb2 object. Read from there as well.

try {
for (var k in hmetas) {
if (typeof hmetas[k] == 'object') {
var mname = hmetas[k].name || hmetas[k].getAttribute('property');
var mcont = hmetas[k].content;
if (!!mname && mname != 'null' && !!mcont) {
if (wnames.indexOf(mname) >= 0) {
if (!mts[mname]) {
mts[mname] = [];
}
mts[mname].push(mcont);
}
}
}
}
mts['title'] = [(document.getElementsByTagName('title')[0] || []).innerHTML];
mts['base'] = [(document.getElementsByTagName('base')[0] || {}).href];
mts['referer'] = [document.location.href];
mts['ortb2'] = (config.getConfig('ortb2') || {});
} catch (e) {
mts.error = e;
}
return mts;
}

function formRequestUrl(reqData) {
var key;
var url = [];
Expand Down Expand Up @@ -107,9 +137,14 @@ export const spec = {
bidObject.gdpr = bidRequest.gdpr.gdpr;
bidObject.gdpr_consent = bidRequest.gdpr.gdpr_consent;
}

if (bid.adomain) {
utils.deepSetValue(bidObject, 'meta.advertiserDomains', Array.isArray(bid.adomain) ? bid.adomain : [bid.adomain]);
}
bidRespones.push(bidObject);
}
}

return bidRespones;

function verifySize(adItem, validSizes) {
Expand Down
5 changes: 5 additions & 0 deletions test/spec/modules/etargetBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,11 @@ describe('etarget adapter', function () {
assert.lengthOf(parsedUrl.items, 7);
});

it('should be an object', function () {
let request = spec.buildRequests(bids);
assert.isNotNull(request.metaData);
});

it('should handle global request parameters', function () {
let parsedUrl = parseUrl(spec.buildRequests([bids[0]]).url);
assert.equal(parsedUrl.path, 'https://sk.search.etargetnet.com/hb');
Expand Down