Skip to content

Commit f8b1bd6

Browse files
Ji Limeta-codesync[bot]
authored andcommitted
add new AMM fields to attribution_data
Summary: Update business SDK to include new AMM fields in attribution data: attribution_source -touchpoint_type -touchpoint_ts Reviewed By: satwikareddy3, daegwang Differential Revision: D83916694 Privacy Context Container: L1390617 fbshipit-source-id: eb964c937f20e758d9f3c7d0f4a341bef1950882
1 parent 69e6e34 commit f8b1bd6

File tree

3 files changed

+151
-9
lines changed

3 files changed

+151
-9
lines changed

CHANGELOG.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file.
55

66
## Unreleased
77

8+
## v24.0.0
9+
10+
11+
### Added
12+
- Add AMM fields to attribution data
13+
814
## v17.0.0
915

1016

@@ -112,4 +118,3 @@ All notable changes to this project will be documented in this file.
112118
## v3.3.0
113119
### Changed
114120
- Graph API call upgrade to [v3.3](https://developers.facebook.com/docs/graph-api/changelog/version3.3)
115-

src/main/java/com/facebook/ads/sdk/serverside/AttributionData.java

Lines changed: 113 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,15 @@ public class AttributionData {
4747

4848
@SerializedName("attribution_value")
4949
private Float attributionValue = null;
50+
51+
@SerializedName("attribution_source")
52+
private String attributionSource = null;
53+
54+
@SerializedName("touchpoint_type")
55+
private String touchpointType = null;
56+
57+
@SerializedName("touchpoint_ts")
58+
private Integer touchpointTs = null;
5059

5160
/**
5261
* Default constructor
@@ -64,10 +73,15 @@ public AttributionData() {
6473
* @param campaignId Meta-provided campaign id from URL/deeplink
6574
* @param attributionShare [0-1] weight of credit assigned to the visit
6675
* @param attributionModel Attribution model used to attribute the event
76+
* @param attributionWindow Attribution window in days
6777
* @param attributionValue The share of value generated by this click-conversion pair that is attributed to Meta.
78+
* @param attributionSource The attribution source to differentiate the source of the data, e.g. whether this is from AMM or Custom Attribution or any other sources.
79+
* @param touchpointType The engagement type that caused the original credited conversion.
80+
* @param touchpointTs The time when the touchpoint event occurred with the ad that the install was credited to.
6881
*/
6982
public AttributionData(String scope, Long visitTime, String adId, String adsetId, String campaignId,
70-
Float attributionShare, AttributionModelEnum attributionModel, Integer attributionWindow, Float attributionValue) {
83+
Float attributionShare, AttributionModelEnum attributionModel, Integer attributionWindow, Float attributionValue,
84+
String attributionSource, String touchpointType, Integer touchpointTs) {
7185
this.scope = scope;
7286
this.visitTime = visitTime;
7387
this.adId = adId;
@@ -77,6 +91,9 @@ public AttributionData(String scope, Long visitTime, String adId, String adsetId
7791
this.attributionModel = attributionModel;
7892
this.attributionWindow = attributionWindow;
7993
this.attributionValue = attributionValue;
94+
this.attributionSource = attributionSource;
95+
this.touchpointType = touchpointType;
96+
this.touchpointTs = touchpointTs;
8097
}
8198

8299
/**
@@ -340,6 +357,93 @@ public void setAttributionValue(Float attributionValue) {
340357
this.attributionValue = attributionValue;
341358
}
342359

360+
/**
361+
* Set attributionSource
362+
*
363+
* @param attributionSource The attribution source to differentiate the source of the data, e.g. whether this is from AMM or Custom Attribution or any other sources.
364+
* @return AttributionData
365+
*/
366+
public AttributionData attributionSource(String attributionSource) {
367+
this.attributionSource = attributionSource;
368+
return this;
369+
}
370+
371+
/**
372+
* Get attributionSource
373+
*
374+
* @return attributionSource
375+
*/
376+
public String getAttributionSource() {
377+
return attributionSource;
378+
}
379+
380+
/**
381+
* Set attributionSource
382+
*
383+
* @param attributionSource The attribution source to differentiate the source of the data, e.g. whether this is from AMM or Custom Attribution or any other sources.
384+
*/
385+
public void setAttributionSource(String attributionSource) {
386+
this.attributionSource = attributionSource;
387+
}
388+
389+
/**
390+
* Set touchpointType
391+
*
392+
* @param touchpointType The engagement type that caused the original credited conversion.
393+
* @return AttributionData
394+
*/
395+
public AttributionData touchpointType(String touchpointType) {
396+
this.touchpointType = touchpointType;
397+
return this;
398+
}
399+
400+
/**
401+
* Get touchpointType
402+
*
403+
* @return touchpointType
404+
*/
405+
public String getTouchpointType() {
406+
return touchpointType;
407+
}
408+
409+
/**
410+
* Set touchpointType
411+
*
412+
* @param touchpointType The engagement type that caused the original credited conversion.
413+
*/
414+
public void setTouchpointType(String touchpointType) {
415+
this.touchpointType = touchpointType;
416+
}
417+
418+
/**
419+
* Set touchpointTs
420+
*
421+
* @param touchpointTs The time when the touchpoint event occurred with the ad that the install was credited to.
422+
* @return AttributionData
423+
*/
424+
public AttributionData touchpointTs(Integer touchpointTs) {
425+
this.touchpointTs = touchpointTs;
426+
return this;
427+
}
428+
429+
/**
430+
* Get touchpointTs
431+
*
432+
* @return touchpointTs
433+
*/
434+
public Integer getTouchpointTs() {
435+
return touchpointTs;
436+
}
437+
438+
/**
439+
* Set touchpointTs
440+
*
441+
* @param touchpointTs The time when the touchpoint event occurred with the ad that the install was credited to.
442+
*/
443+
public void setTouchpointTs(Integer touchpointTs) {
444+
this.touchpointTs = touchpointTs;
445+
}
446+
343447
@Override
344448
public boolean equals(Object o) {
345449
if (this == o) return true;
@@ -355,12 +459,15 @@ public boolean equals(Object o) {
355459
&& Objects.equals(this.attributionShare, attributionData.attributionShare)
356460
&& Objects.equals(this.attributionModel, attributionData.attributionModel)
357461
&& Objects.equals(this.attributionWindow, attributionData.attributionWindow)
358-
&& Objects.equals(this.attributionValue, attributionData.attributionValue);
462+
&& Objects.equals(this.attributionValue, attributionData.attributionValue)
463+
&& Objects.equals(this.attributionSource, attributionData.attributionSource)
464+
&& Objects.equals(this.touchpointType, attributionData.touchpointType)
465+
&& Objects.equals(this.touchpointTs, attributionData.touchpointTs);
359466
}
360467

361468
@Override
362469
public int hashCode() {
363-
return Objects.hash(scope, visitTime, adId, adsetId, campaignId, attributionShare, attributionModel, attributionWindow, attributionValue);
470+
return Objects.hash(scope, visitTime, adId, adsetId, campaignId, attributionShare, attributionModel, attributionWindow, attributionValue, attributionSource, touchpointType, touchpointTs);
364471
}
365472

366473
@Override
@@ -376,6 +483,9 @@ public String toString() {
376483
sb.append(" attributionModel: ").append(toIndentedString(attributionModel)).append("\n");
377484
sb.append(" attributionWindow: ").append(toIndentedString(attributionWindow)).append("\n");
378485
sb.append(" attributionValue: ").append(toIndentedString(attributionValue)).append("\n");
486+
sb.append(" attributionSource: ").append(toIndentedString(attributionSource)).append("\n");
487+
sb.append(" touchpointType: ").append(toIndentedString(touchpointType)).append("\n");
488+
sb.append(" touchpointTs: ").append(toIndentedString(touchpointTs)).append("\n");
379489
sb.append("}");
380490
return sb.toString();
381491
}

src/test/java/com/facebook/ads/sdk/serverside/AttributionDataTest.java

Lines changed: 32 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,9 @@ public void TestAttributionDataBuilderAndGetters() {
3535
float attributionShare = 0.5f;
3636
float attributionValue = 0.3f;
3737
AttributionModelEnum attributionModel = AttributionModelEnum.LAST_CLICK;
38+
String attributionSource = "amm";
39+
String touchpointType = "onsite_click";
40+
int touchpointTs = 123;
3841

3942
attributionData
4043
.scope(scope)
@@ -45,7 +48,10 @@ public void TestAttributionDataBuilderAndGetters() {
4548
.attributionWindow(attributionWindow)
4649
.attributionShare(attributionShare)
4750
.attributionModel(attributionModel)
48-
.attributionValue(attributionValue);
51+
.attributionValue(attributionValue)
52+
.attributionSource(attributionSource)
53+
.touchpointType(touchpointType)
54+
.touchpointTs(touchpointTs);
4955

5056
assertEquals(attributionData.getScope(), scope);
5157
assertEquals(attributionData.getAdId(), adId);
@@ -56,6 +62,9 @@ public void TestAttributionDataBuilderAndGetters() {
5662
assertEquals((long) attributionData.getVisitTime(), visitTime);
5763
assertEquals(attributionData.getAttributionModel(), attributionModel);
5864
assertEquals((float)attributionData.getAttributionValue(), attributionValue, 0);
65+
assertEquals(attributionData.getAttributionSource(), attributionSource);
66+
assertEquals(attributionData.getTouchpointType(), touchpointType);
67+
assertEquals((int)attributionData.getTouchpointTs(), touchpointTs);
5968
}
6069

6170
@Test
@@ -71,6 +80,9 @@ public void TestWhenInstancesAreEqual() {
7180
float attributionShare = 0.5f;
7281
float attributionValue = 0.3f;
7382
AttributionModelEnum attributionModel = AttributionModelEnum.LAST_CLICK;
83+
String attributionSource = "amm";
84+
String touchpointType = "onsite_click";
85+
int touchpointTs = 123;
7486

7587
attributionData1
7688
.scope(scope)
@@ -81,7 +93,10 @@ public void TestWhenInstancesAreEqual() {
8193
.attributionWindow(attributionWindow)
8294
.attributionShare(attributionShare)
8395
.attributionModel(attributionModel)
84-
.attributionValue(attributionValue);
96+
.attributionValue(attributionValue)
97+
.attributionSource(attributionSource)
98+
.touchpointType(touchpointType)
99+
.touchpointTs(touchpointTs);
85100

86101
attributionData2
87102
.scope(scope)
@@ -92,7 +107,10 @@ public void TestWhenInstancesAreEqual() {
92107
.attributionWindow(attributionWindow)
93108
.attributionShare(attributionShare)
94109
.attributionModel(attributionModel)
95-
.attributionValue(attributionValue);
110+
.attributionValue(attributionValue)
111+
.attributionSource(attributionSource)
112+
.touchpointType(touchpointType)
113+
.touchpointTs(touchpointTs);
96114

97115
assertEquals(attributionData1, attributionData2);
98116
assertEquals(attributionData1.hashCode(), attributionData2.hashCode());
@@ -110,6 +128,9 @@ public void TestWhenInstancesAreNotEqual() {
110128
float attributionShare = 0.5f;
111129
float attributionValue = 0.3f;
112130
AttributionModelEnum attributionModel = AttributionModelEnum.LAST_CLICK;
131+
String attributionSource = "amm";
132+
String touchpointType = "onsite_click";
133+
int touchpointTs = 123;
113134

114135
// set different attribution windown to test
115136
attributionData1
@@ -121,7 +142,10 @@ public void TestWhenInstancesAreNotEqual() {
121142
.attributionWindow(28)
122143
.attributionShare(attributionShare)
123144
.attributionModel(attributionModel)
124-
.attributionValue(attributionValue);
145+
.attributionValue(attributionValue)
146+
.attributionSource(attributionSource)
147+
.touchpointType(touchpointType)
148+
.touchpointTs(touchpointTs);
125149

126150
attributionData2
127151
.scope(scope)
@@ -132,7 +156,10 @@ public void TestWhenInstancesAreNotEqual() {
132156
.attributionWindow(7)
133157
.attributionShare(attributionShare)
134158
.attributionModel(attributionModel)
135-
.attributionValue(attributionValue);
159+
.attributionValue(attributionValue)
160+
.attributionSource(attributionSource)
161+
.touchpointType(touchpointType)
162+
.touchpointTs(touchpointTs);
136163

137164
assertNotEquals(attributionData1, attributionData2);
138165
assertNotEquals(attributionData1.hashCode(), attributionData2.hashCode());

0 commit comments

Comments
 (0)