Skip to content

Commit a68f7e2

Browse files
authored
Sharethrough: Add support for GPID (prebid#1925)
1 parent 0aa427e commit a68f7e2

File tree

4 files changed

+33
-6
lines changed

4 files changed

+33
-6
lines changed

adapters/sharethrough/butler.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ const defaultTmax = 10000 // 10 sec
2121
type StrAdSeverParams struct {
2222
Pkey string
2323
BidID string
24+
GPID string
2425
ConsentRequired bool
2526
ConsentString string
2627
USPrivacySignal string
@@ -97,6 +98,11 @@ func (s StrOpenRTBTranslator) requestFromOpenRTB(imp openrtb2.Imp, request *open
9798
return nil, err
9899
}
99100

101+
var gpid string
102+
if strImpParams.Data != nil && strImpParams.Data.PBAdSlot != "" {
103+
gpid = strImpParams.Data.PBAdSlot
104+
}
105+
100106
usPolicySignal := ""
101107
if usPolicy, err := ccpa.ReadFromRequest(request); err == nil {
102108
usPolicySignal = usPolicy.Consent
@@ -107,6 +113,7 @@ func (s StrOpenRTBTranslator) requestFromOpenRTB(imp openrtb2.Imp, request *open
107113
Uri: s.UriHelper.buildUri(StrAdSeverParams{
108114
Pkey: pKey,
109115
BidID: imp.ID,
116+
GPID: gpid,
110117
ConsentRequired: s.Util.gdprApplies(request),
111118
ConsentString: userInfo.Consent,
112119
USPrivacySignal: usPolicySignal,
@@ -191,6 +198,9 @@ func (h StrUriHelper) buildUri(params StrAdSeverParams) string {
191198
v := url.Values{}
192199
v.Set("placement_key", params.Pkey)
193200
v.Set("bidId", params.BidID)
201+
if params.GPID != "" {
202+
v.Set("gpid", params.GPID)
203+
}
194204
v.Set("consent_required", fmt.Sprintf("%t", params.ConsentRequired))
195205
v.Set("consent_string", params.ConsentString)
196206
if params.USPrivacySignal != "" {

adapters/sharethrough/butler_test.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ func TestSuccessRequestFromOpenRTB(t *testing.T) {
8383
"Generates the correct AdServer request from Imp (no user provided)": {
8484
inputImp: openrtb2.Imp{
8585
ID: "abc",
86-
Ext: []byte(`{ "bidder": {"pkey": "pkey", "iframe": true, "iframeSize": [10, 20], "bidfloor": 1.0} }`),
86+
Ext: []byte(`{ "bidder": {"pkey": "pkey", "iframe": true, "iframeSize": [10, 20], "bidfloor": 1.0, "data": { "pbadslot": "adslot" } } }`),
8787
Banner: &openrtb2.Banner{
8888
Format: []openrtb2.Format{{H: 30, W: 40}},
8989
},
@@ -435,6 +435,7 @@ func TestBuildUri(t *testing.T) {
435435
inputParams: StrAdSeverParams{
436436
Pkey: "pkey",
437437
BidID: "bid",
438+
GPID: "gpid",
438439
ConsentRequired: true,
439440
ConsentString: "consent",
440441
USPrivacySignal: "ccpa",
@@ -449,6 +450,7 @@ func TestBuildUri(t *testing.T) {
449450
"http://abc.com?",
450451
"placement_key=pkey",
451452
"bidId=bid",
453+
"gpid=gpid",
452454
"consent_required=true",
453455
"consent_string=consent",
454456
"us_privacy=ccpa",

openrtb_ext/imp_sharethrough.go

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,18 @@
11
package openrtb_ext
22

3-
type ExtImpSharethrough struct {
4-
Pkey string `json:"pkey"`
5-
Iframe bool `json:"iframe"`
6-
IframeSize []int `json:"iframeSize"`
7-
BidFloor float64 `json:"bidfloor"`
3+
type ExtData struct {
4+
PBAdSlot string `json:"pbadslot"`
85
}
96

107
// ExtImpSharethrough defines the contract for bidrequest.imp[i].ext.sharethrough
8+
type ExtImpSharethrough struct {
9+
Pkey string `json:"pkey"`
10+
Iframe bool `json:"iframe"`
11+
IframeSize []int `json:"iframeSize"`
12+
BidFloor float64 `json:"bidfloor"`
13+
Data *ExtData `json:"data,omitempty"`
14+
}
15+
1116
type ExtImpSharethroughResponse struct {
1217
AdServerRequestID string `json:"adserverRequestId"`
1318
BidID string `json:"bidId"`

static/bidder-params/sharethrough.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,16 @@
2626
"bidfloor": {
2727
"type": "number",
2828
"description": "The floor price, or minimum amount, a publisher will accept for an impression, given in CPM in USD"
29+
},
30+
"data": {
31+
"type": "object",
32+
"description": "Ad-specific first party data",
33+
"properties": {
34+
"pbadslot": {
35+
"type": "string",
36+
"description": "Prebid Ad Slot, see: https://docs.prebid.org/features/pbAdSlot.html"
37+
}
38+
}
2939
}
3040
},
3141
"required": ["pkey"]

0 commit comments

Comments
 (0)