Skip to content

Commit 71ffead

Browse files
authored
EXCH-13317 Provide GPP params for user sync (prebid#13628)
1 parent d2a47f4 commit 71ffead

2 files changed

Lines changed: 135 additions & 1 deletion

File tree

modules/openxBidAdapter.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,9 +207,10 @@ function interpretResponse(resp, req) {
207207
* @param responses
208208
* @param gdprConsent
209209
* @param uspConsent
210+
* @param gppConsent
210211
* @return {{type: (string), url: (*|string)}[]}
211212
*/
212-
function getUserSyncs(syncOptions, responses, gdprConsent, uspConsent) {
213+
function getUserSyncs(syncOptions, responses, gdprConsent, uspConsent, gppConsent) {
213214
if (syncOptions.iframeEnabled || syncOptions.pixelEnabled) {
214215
const pixelType = syncOptions.iframeEnabled ? 'iframe' : 'image';
215216
const queryParamStrings = [];
@@ -221,6 +222,10 @@ function getUserSyncs(syncOptions, responses, gdprConsent, uspConsent) {
221222
if (uspConsent) {
222223
queryParamStrings.push('us_privacy=' + encodeURIComponent(uspConsent));
223224
}
225+
if (gppConsent?.gppString && gppConsent?.applicableSections?.length) {
226+
queryParamStrings.push('gpp=' + encodeURIComponent(gppConsent.gppString));
227+
queryParamStrings.push('gpp_sid=' + gppConsent.applicableSections.join(','));
228+
}
224229
if (responses.length > 0 && responses[0].body && responses[0].body.ext) {
225230
const ext = responses[0].body.ext;
226231
if (ext.delDomain) {

test/spec/modules/openxBidAdapter_spec.js

Lines changed: 129 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -988,6 +988,35 @@ describe('OpenxRtbAdapter', function () {
988988
expect(request[1].data.imp[0].ext.consent).to.equal(undefined);
989989
});
990990
});
991+
992+
describe('GPP', function () {
993+
it('should send GPP string and GPP section IDs in bid request when available', async function () {
994+
bidderRequest.bids = bidRequests;
995+
bidderRequest.ortb2 = {
996+
regs: {
997+
gpp: 'test-gpp-string',
998+
gpp_sid: [6]
999+
}
1000+
};
1001+
const request = spec.buildRequests(bidRequests, bidderRequest);
1002+
expect(request[0].data.regs.gpp).to.equal('test-gpp-string');
1003+
expect(request[0].data.regs.gpp_sid).to.deep.equal([6]);
1004+
expect(request[1].data.regs.gpp).to.equal('test-gpp-string');
1005+
expect(request[1].data.regs.gpp_sid).to.deep.equal([6]);
1006+
});
1007+
1008+
it('should not send GPP string and GPP section IDs in bid request when not available', async function () {
1009+
bidderRequest.bids = bidRequests;
1010+
bidderRequest.ortb2 = {
1011+
regs: {}
1012+
};
1013+
const request = spec.buildRequests(bidRequests, bidderRequest);
1014+
expect(request[0].data.regs.gpp).to.not.exist;
1015+
expect(request[0].data.regs.gpp_sid).to.not.exist;
1016+
expect(request[1].data.regs.gpp).to.not.exist;
1017+
expect(request[1].data.regs.gpp_sid).to.not.exist;
1018+
});
1019+
});
9911020
});
9921021

9931022
context('coppa', function() {
@@ -2031,6 +2060,106 @@ describe('OpenxRtbAdapter', function () {
20312060
});
20322061
});
20332062

2063+
describe('when gpp applies', function () {
2064+
it('should send GPP query params when GPP consent object available', () => {
2065+
const gppConsent = {
2066+
gppString: 'gpp-pixel-consent',
2067+
applicableSections: [6, 7]
2068+
}
2069+
const [{url}] = spec.getUserSyncs(
2070+
{iframeEnabled: true, pixelEnabled: true},
2071+
[],
2072+
undefined,
2073+
undefined,
2074+
gppConsent
2075+
);
2076+
2077+
expect(url).to.have.string(`gpp=gpp-pixel-consent`);
2078+
expect(url).to.have.string(`gpp_sid=6,7`);
2079+
});
2080+
2081+
it('should send GDPR and GPP query params when both consent objects available', () => {
2082+
const gdprConsent = {
2083+
consentString: 'gdpr-pixel-consent',
2084+
gdprApplies: true
2085+
}
2086+
const gppConsent = {
2087+
gppString: 'gpp-pixel-consent',
2088+
applicableSections: [6, 7]
2089+
}
2090+
const [{url}] = spec.getUserSyncs(
2091+
{iframeEnabled: true, pixelEnabled: true},
2092+
[],
2093+
gdprConsent,
2094+
undefined,
2095+
gppConsent
2096+
);
2097+
2098+
expect(url).to.have.string(`gdpr_consent=gdpr-pixel-consent`);
2099+
expect(url).to.have.string(`gdpr=1`);
2100+
expect(url).to.have.string(`gpp=gpp-pixel-consent`);
2101+
expect(url).to.have.string(`gpp_sid=6,7`);
2102+
});
2103+
2104+
it('should not send GPP query params when GPP string not available', function () {
2105+
const gppConsent = {
2106+
applicableSections: [6, 7]
2107+
}
2108+
const [{url}] = spec.getUserSyncs(
2109+
{iframeEnabled: true, pixelEnabled: true},
2110+
[],
2111+
undefined,
2112+
undefined,
2113+
gppConsent
2114+
);
2115+
2116+
expect(url).to.not.have.string('gpp=');
2117+
expect(url).to.not.have.string('gpp_sid=');
2118+
});
2119+
2120+
it('should not send GPP query params when GPP section IDs not available', function () {
2121+
const gppConsent = {
2122+
gppString: 'gpp-pixel-consent',
2123+
}
2124+
const [{url}] = spec.getUserSyncs(
2125+
{iframeEnabled: true, pixelEnabled: true},
2126+
[],
2127+
undefined,
2128+
undefined,
2129+
gppConsent
2130+
);
2131+
2132+
expect(url).to.not.have.string('gpp=');
2133+
expect(url).to.not.have.string('gpp_sid=');
2134+
});
2135+
2136+
it('should not send GPP query params when GPP section IDs empty', function () {
2137+
const gppConsent = {
2138+
gppString: 'gpp-pixel-consent',
2139+
applicableSections: []
2140+
}
2141+
const [{url}] = spec.getUserSyncs(
2142+
{iframeEnabled: true, pixelEnabled: true},
2143+
[],
2144+
undefined,
2145+
undefined,
2146+
gppConsent
2147+
);
2148+
2149+
expect(url).to.not.have.string('gpp=');
2150+
expect(url).to.not.have.string('gpp_sid=');
2151+
});
2152+
2153+
it('should not send GPP query params when GPP consent object not available', function () {
2154+
const [{url}] = spec.getUserSyncs(
2155+
{iframeEnabled: true, pixelEnabled: true},
2156+
[], undefined, undefined, undefined
2157+
);
2158+
expect(url).to.not.have.string('gpp=');
2159+
expect(url).to.not.have.string('gpp_sid=');
2160+
});
2161+
});
2162+
20342163
describe('when ccpa applies', function () {
20352164
let usPrivacyConsent;
20362165
let uspPixelUrl;

0 commit comments

Comments
 (0)