You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+42Lines changed: 42 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -56,6 +56,48 @@ To add properties that are tracked in every event, you can set properties for a
56
56
userProperties.key = "value";
57
57
amplitude.setUserProperties(userProperties);
58
58
59
+
# User Property Operations #
60
+
61
+
The SDK supports the operations set, setOnce, unset, and add on individual user properties. The operations are declared via a provided `Identify` interface. Multiple operations can be chained together in a single `Identify` object. The `Identify` object is then passed to the Amplitude client to send to the server. The results of the operations will be visible immediately in the dashboard, and take effect for events logged after.
62
+
63
+
1.`set`: this sets the value of a user property.
64
+
65
+
```javascript
66
+
var identify =newamplitude.Identify().set('gender', 'female').set('age', 20);
67
+
amplitude.identify(identify);
68
+
```
69
+
70
+
2.`setOnce`:this sets the value of a user property only once. Subsequent`setOnce` operations on that user property will be ignored. In the following example, `sign_up_date` will be set once to `08/24/2015`, and the following setOnce to `09/14/2015` will be ignored:
71
+
72
+
```javascript
73
+
var identify = new amplitude.Identify().setOnce('sign_up_date', '08/24/2015');
74
+
amplitude.identify(identify);
75
+
76
+
var identify = new amplitude.Identify().setOnce('sign_up_date', '09/14/2015');
77
+
amplitude.identify(identify);
78
+
```
79
+
80
+
3.`unset`:this will unset and remove a user property.
81
+
82
+
```javascript
83
+
var identify = new amplitude.Identify().unset('gender').unset('age');
84
+
amplitude.identify(identify);
85
+
```
86
+
87
+
4.`add`:this will increment a user property by some numerical value. If the user property does not have a value set yet, it will be initialized to 0 before being incremented.
88
+
89
+
```javascript
90
+
var identify = new amplitude.Identify().add('karma', 1).add('friends', 1);
91
+
amplitude.identify(identify);
92
+
```
93
+
94
+
Note:if a user property is used in multiple operations on the same `Identify` object, only the first operation will be saved, and the rest will be ignored. Inthis example, only the set operation will be saved, and the add and unset will be ignored:
95
+
96
+
```javascript
97
+
var identify = new amplitude.Identify().set('karma', 10).add('karma', 1).unset('karma');
0 commit comments