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

Adloox Analytics/RTD: prefer gpid over pbadslot #8455

Merged
merged 2 commits into from
May 26, 2022
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
14 changes: 9 additions & 5 deletions modules/adlooxAnalyticsAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,15 +63,15 @@ MACRO['pageurl'] = function(b, c) {
const refererInfo = getRefererInfo();
return (refererInfo.canonicalUrl || refererInfo.referer || '').substr(0, 300).split(/[?#]/)[0];
};
MACRO['pbadslot'] = function(b, c) {
MACRO['gpid'] = function(b, c) {
const adUnit = find(auctionManager.getAdUnits(), a => b.adUnitCode === a.code);
return deepAccess(adUnit, 'ortb2Imp.ext.data.pbadslot') || getGptSlotInfoForAdUnitCode(b.adUnitCode).gptSlot || b.adUnitCode;
return deepAccess(adUnit, 'ortb2Imp.ext.gpid') || deepAccess(adUnit, 'ortb2Imp.ext.data.pbadslot') || getGptSlotInfoForAdUnitCode(b.adUnitCode).gptSlot || b.adUnitCode;
};
MACRO['pbAdSlot'] = MACRO['pbadslot']; // legacy
MACRO['pbAdSlot'] = MACRO['pbadslot'] = MACRO['gpid']; // legacy

const PARAMS_DEFAULT = {
'id1': function(b) { return b.adUnitCode },
'id2': '%%pbadslot%%',
'id2': '%%gpid%%',
'id3': function(b) { return b.bidder },
'id4': function(b) { return b.adId },
'id5': function(b) { return b.dealId },
Expand Down Expand Up @@ -138,7 +138,11 @@ analyticsAdapter.enableAnalytics = function(config) {
toselector: config.options.toselector || function(bid) {
let code = getGptSlotInfoForAdUnitCode(bid.adUnitCode).divId || bid.adUnitCode;
// https://mathiasbynens.be/notes/css-escapes
code = code.replace(/^\d/, '\\3$& ');
try {
code = CSS.escape(code);
} catch (_) {
code = code.replace(/^\d/, '\\3$& ');
}
return `#${code}`
},
client: config.options.client,
Expand Down
6 changes: 3 additions & 3 deletions modules/adlooxAnalyticsAdapter.md
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ For example, you have a number of reporting breakdown slots available in the for
tagid: 0,
params: {
id1: function(b) { return b.adUnitCode }, // do not change when using the Adloox RTD Provider
id2: '%%pbadslot%%', // do not change when using the Adloox RTD Provider
id2: '%%gpid%%', // do not change when using the Adloox RTD Provider
id3: function(b) { return b.bidder },
id4: function(b) { return b.adId },
id5: function(b) { return b.dealId },
Expand All @@ -125,9 +125,9 @@ For example, you have a number of reporting breakdown slots available in the for

The following macros are available

* `%%pbadslot%%`: [Prebid Ad Slot](https://docs.prebid.org/features/pbAdSlot.html) returns [`AdUnit.code`](https://docs.prebid.org/features/pbAdSlot.html) if set otherwise returns [`AdUnit.code`](https://docs.prebid.org/dev-docs/adunit-reference.html#adunit)
* **`%%gpid%%` (alias `%%pbadslot%%`**): [Prebid Ad Slot](https://docs.prebid.org/features/pbAdSlot.html) returns [`AdUnit.code`](https://docs.prebid.org/features/pbAdSlot.html) if set otherwise returns [`AdUnit.code`](https://docs.prebid.org/dev-docs/adunit-reference.html#adunit)
* it is recommended you read the [Prebid Ad Slot section in the Adloox RTD Provider documentation](./adlooxRtdProvider.md#prebid-ad-slot)
* `%%pageurl%%`: [`canonicalUrl`](https://docs.prebid.org/dev-docs/publisher-api-reference/setConfig.html#setConfig-Page-URL) from the [`refererInfo` object](https://docs.prebid.org/dev-docs/bidder-adaptor.html#referrers) otherwise uses `referer`
* **`%%pageurl%%`**: [`canonicalUrl`](https://docs.prebid.org/dev-docs/publisher-api-reference/setConfig.html#setConfig-Page-URL) from the [`refererInfo` object](https://docs.prebid.org/dev-docs/bidder-adaptor.html#referrers) otherwise uses `referer`

### Functions

Expand Down
8 changes: 3 additions & 5 deletions modules/adlooxRtdProvider.js
Original file line number Diff line number Diff line change
Expand Up @@ -216,13 +216,11 @@ function init(config, userConsent) {
function getBidRequestData(reqBidsConfigObj, callback, config, userConsent) {
// gptPreAuction runs *after* RTD so pbadslot may not be populated... (╯°□°)╯ ┻━┻
const adUnits = (reqBidsConfigObj.adUnits || getGlobal().adUnits).map(adUnit => {
let path = deepAccess(adUnit, 'ortb2Imp.ext.data.pbadslot');
if (!path) path = getGptSlotInfoForAdUnitCode(adUnit.code).gptSlot;
return {
path: path,
gpid: deepAccess(adUnit, 'ortb2Imp.ext.gpid') || deepAccess(adUnit, 'ortb2Imp.ext.data.pbadslot') || getGptSlotInfoForAdUnitCode(adUnit.code).gptSlot || adUnit.code,
unit: adUnit
};
}).filter(adUnit => !!adUnit.path);
}).filter(adUnit => !!adUnit.gpid);

let response = {};
function setSegments() {
Expand Down Expand Up @@ -315,7 +313,7 @@ function getBidRequestData(reqBidsConfigObj, callback, config, userConsent) {
}
const atfQueue = [];
adUnits.map((adUnit, i) => {
const ref = [ adUnit.path ];
const ref = [ adUnit.gpid ];
if (!config.params.slotinpath) ref.push(adUnit.unit.code);
args.push(['s', ref.join('\t')]);

Expand Down
4 changes: 2 additions & 2 deletions modules/adlooxRtdProvider.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ To use this, you *must* also integrate the [Adloox Analytics Adapter](./adlooxAn

You may optionally pass a subsection `params` in the `params` block to the Adloox RTD Provider, these will be passed through to the segment handler as is and as described by the integration guidelines.

**N.B.** If you pass `params` to the Adloox Analytics Adapter, `id1` (`AdUnit.code`) and `id2` (`%%pbadslot%%`) *must* describe a stable identifier otherwise no usable segments will be served and so they *must not* be changed; if `id1` for your inventory could contain a non-stable random number please consult with us before continuing
**N.B.** If you pass `params` to the Adloox Analytics Adapter, `id1` (`AdUnit.code`) and `id2` (`%%gpid%%`) *must* describe a stable identifier otherwise no usable segments will be served and so they *must not* be changed; if `id1` for your inventory could contain a non-stable random number please consult with us before continuing

Though our segment technology is fast (less than 10ms) the time it takes for the users device to connect to our service and fetch the segments may not be. For this reason we recommend setting `auctionDelay` no lower than 100ms and if possible you should explore using user-agent sourced information such as [NetworkInformation.{rtt,downlink,...}](https://developer.mozilla.org/en-US/docs/Web/API/NetworkInformation) to dynamically tune this for each user.

Expand All @@ -94,7 +94,7 @@ You may use one of two ways to do achieve this:
* for display inventory [using GPT](https://developers.google.com/publisher-tag/guides/get-started) you may configure Prebid.js to automatically use the [full ad unit path](https://developers.google.com/publisher-tag/reference#googletag.Slot_getAdUnitPath)
1. include the [`gptPreAuction` module](https://docs.prebid.org/dev-docs/modules/gpt-pre-auction.html)
1. wrap both `pbjs.setConfig({...})` and `pbjs.enableAnalytics({...})` with `googletag.cmd.push(function() { ... })`
* set `pbadslot` in the [first party data](https://docs.prebid.org/dev-docs/adunit-reference.html#first-party-data) variable `AdUnit.ortb2Imp.ext.data.pbadslot` for all your ad units
* set `gpid` (or `pbadslot`) in the [first party data](https://docs.prebid.org/dev-docs/adunit-reference.html#first-party-data) variable `AdUnit.ortb2Imp.ext.gpid` (or `AdUnit.ortb2Imp.ext.data.pbadslot`) for all your ad units

## Timeouts

Expand Down