diff --git a/modules/smartadserverBidAdapter.js b/modules/smartadserverBidAdapter.js index fd2d6e16463..4b7e65cae87 100644 --- a/modules/smartadserverBidAdapter.js +++ b/modules/smartadserverBidAdapter.js @@ -159,6 +159,11 @@ export const spec = { sdc: sellerDefinedContext }; + const gpid = deepAccess(bid, 'ortb2Imp.ext.gpid', deepAccess(bid, 'ortb2Imp.ext.data.pbadslot', '')); + if (gpid) { + payload.gpid = gpid; + } + if (bidderRequest) { if (bidderRequest.gdprConsent) { payload.addtl_consent = bidderRequest.gdprConsent.addtlConsent; diff --git a/test/spec/modules/smartadserverBidAdapter_spec.js b/test/spec/modules/smartadserverBidAdapter_spec.js index 504ff978e9e..9142b730b27 100644 --- a/test/spec/modules/smartadserverBidAdapter_spec.js +++ b/test/spec/modules/smartadserverBidAdapter_spec.js @@ -1,6 +1,7 @@ import { expect } from 'chai'; import { BANNER, VIDEO } from 'src/mediaTypes.js'; import { config } from 'src/config.js'; +import { deepClone } from 'src/utils.js'; import { spec } from 'modules/smartadserverBidAdapter.js'; // Default params with optional ones @@ -1339,4 +1340,45 @@ describe('Smart bid adapter tests', function () { expect(bannerRequest).to.have.property('formatid').and.to.equal('90'); }); }); + + describe('Global Placement ID (GPID)', function () { + it('should not include gpid by default', () => { + const request = spec.buildRequests(DEFAULT_PARAMS_WO_OPTIONAL); + const requestContent = JSON.parse(request[0].data); + + expect(requestContent).to.not.have.property('gdid'); + }); + + it('should include gpid if pbadslot in ortb2Imp', () => { + const gpid = '/19968336/header-bid-tag-1'; + const bidRequests = deepClone(DEFAULT_PARAMS_WO_OPTIONAL); + + bidRequests[0].ortb2Imp = { + ext: { + data: { + pbadslot: gpid + } + } + }; + + const request = spec.buildRequests(bidRequests); + const requestContent = JSON.parse(request[0].data); + + expect(requestContent).to.have.property('gpid').and.to.equal(gpid); + }); + + it('should include gpid if imp[].ext.gpid exists', () => { + const gpid = '/1111/homepage#div-leftnav'; + const bidRequests = deepClone(DEFAULT_PARAMS_WO_OPTIONAL); + + bidRequests[0].ortb2Imp = { + ext: { gpid } + }; + + const request = spec.buildRequests(bidRequests); + const requestContent = JSON.parse(request[0].data); + + expect(requestContent).to.have.property('gpid').and.to.equal(gpid); + }); + }); });