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: CHANGELOG.md
+7-1Lines changed: 7 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,8 +1,14 @@
1
1
## Unreleased
2
2
3
3
* Add support for setting groups for users and events. See the [Readme](https://github.com/amplitude/Amplitude-Javascript#setting-groups) for more information.
4
+
* Add `logRevenueV2` and new `Revenue` class to support logging revenue events with properties, and revenue type. See [Readme](https://github.com/amplitude/Amplitude-Javascript#tracking-revenue) for more info.
5
+
* Add helper method to regenerate a new random deviceId. This can be used to anonymize a user after they log out. Note this is not recommended unless you know what are you doing. See [Readme](https://github.com/amplitude/Amplitude-Javascript#logging-out-and-anonymous-users) for more information.
6
+
7
+
### 2.11.0 (April 14, 2016)
8
+
4
9
* Add tracking of each user's initial_utm parameters (which is captured as a set once operation). Utm parameters are now sent only once per user session.
5
-
* Add documentation for SDK functions. You can take a look [here](https://rawgit.com/amplitude/Amplitude-Javascript/defensive_cleanup/documentation/Amplitude.html). A link has also been added to the Readme.
10
+
* Add documentation for SDK functions. You can take a look [here](https://rawgit.com/amplitude/Amplitude-Javascript/master/documentation/Amplitude.html). A link has also been added to the Readme.
11
+
* Fix cookie test bug. In rare cases, the cookie test failed to delete the key used in testing. Reloading the page generated new keys, filling up the cookie over time. Fixed test to re-use the same key.
@@ -59,16 +60,19 @@ If your app has its own login system that you want to track users with, you can
59
60
amplitude.setUserId('USER_ID_HERE');
60
61
```
61
62
62
-
A user's data will be merged on the backend so that any events up to that point from the same browser will be tracked under the same user. Note: if a user logs out, or you want to log the events under an anonymous user, you may set the userId to `null` like so:
63
+
You can also add the user ID as an argument to the `init` call:
You can also add the user ID as an argument to the `init` call:
69
+
### Logging Out and Anonymous Users ###
70
+
71
+
A user's data will be merged on the backend so that any events up to that point from the same browser will be tracked under the same user. Note: if a user logs out, or you want to log the events under an anonymous user, you need to do 2 things: 1) set the userId to `null` 2) regenerate a new deviceId. After doing that, events coming from the current user will appear as a brand new user in Amplitude dashboards. Note if you choose to do this, then you won't be able to see that the 2 users were using the same browser/device.
The preferred method of tracking revenue for a user now is to use `logRevenueV2()`in conjunction with the provided `Revenue`interface. `Revenue` instances will store each revenue transaction and allow you to define several special revenue properties (such as revenueType, productId, etc) that are used in Amplitude dashboard's Revenue tab. You can now also add event properties to the revenue event, via the eventProperties field. These `Revenue` instance objects are then passed into `logRevenueV2` to send as revenue events to Amplitude servers. This allows us to automatically display data relevant to revenue on the Amplitude website, including average revenue per daily active user (ARPDAU), 1, 7, 14, 30, 60, and 90 day revenue, lifetime value (LTV) estimates, and revenue by advertising campaign cohort and daily/weekly/monthly cohorts.
188
192
193
+
Each time a user generates revenue, you create a `Revenue` object and fill out the revenue properties:
189
194
```javascript
190
-
amplitude.logRevenue(9.99, 1, 'product');
195
+
var revenue = new amplitude.Revenue().setProductId('com.company.productId').setPrice(3.99).setQuantity(3);
196
+
amplitude.logRevenueV2(revenue);
191
197
```
192
198
193
-
The function takes a unit price, a quantity, and a product identifier. Quantity and product identifier are optional parameters.
199
+
`productId` and `price` are required fields. `quantity` defaults to 1 if not specified. Each field has a corresponding `set` method (for example `setProductId`, `setQuantity`, etc). This table describes the different fields available:
| productId | String | Required: an identifier for the product (we recommend something like the Google Play Store product Id) | null |
204
+
| quantity | Integer | Required: the quantity of products purchased. Defaults to 1 if not specified. Revenue = quantity * price | 1 |
205
+
| price | Double | Required: the price of the products purchased (can be negative). Revenue = quantity * price | null |
206
+
| revenueType | String | Optional: the type of revenue (ex: tax, refund, income) | null |
207
+
| eventProperties | Object | Optional: an object of event properties to include in the revenue event | null |
208
+
209
+
Note: the price can be negative, which might be useful for tracking revenue lost, for example refunds or costs. Also note, you can set event properties on the revenue event just as you would with logEvent by passing in a object of string key value pairs. These event properties, however, will only appear in the Event Segmentation tab, not in the Revenue tab.
194
210
195
-
This allows us to automatically display data relevant to revenue on the Amplitude website, including average revenue per daily active user (ARPDAU), 7, 30, and 90 day revenue, lifetime value (LTV) estimates, and revenue by advertising campaign cohort and daily/weekly/monthly cohorts.
211
+
### Backwards compatibility ###
212
+
213
+
The existing `logRevenue` methods still work but are deprecated. Fields such as `revenueType` will be missing from events logged with the old methods, so Revenue segmentation on those events will be limited in Amplitude dashboards.
| batchEvents | Boolean | If `true`, events are batched together and uploaded only when the number of unsent events is greater than or equal to `eventUploadThreshold` or after `eventUploadPeriodMillis` milliseconds have passed |`false`|
232
-
| cookieExpiration | Number | The number of days after which the Amplitude cookie will expire | 365\*10 (10 years) |
233
-
| cookieName | String | Custom name for the Amplitude cookie |`'amplitude_id'`|
234
-
| deviceId | String | Custom device ID to set. Note this is not recommended unless you really know what you are doing (like if you have your own system for tracking user devices) | Randomly generated UUID |
235
-
| domain | String | Custom cookie domain | The top domain of the current page's url |
236
-
| eventUploadPeriodMillis | Number | Amount of time in milliseconds that the SDK waits before uploading events if `batchEvents` is `true`| 30\*1000 (30 sec) |
237
-
| eventUploadThreshold | Number | Minimum number of events to batch together per request if `batchEvents` is `true`| 30 |
238
-
| includeReferrer | Boolean | If `true`, captures the `referrer` and `referring_domain` for each session, as well as the user's `initial_referrer` and `initial_referring_domain` via a set once operation |`false`|
239
-
| includeUtm | Boolean | If `true`, finds utm parameters in the query string or the __utmz cookie, parses, and includes them as user propeties on all events uploaded |`false`|
240
-
| language | String | Custom language to set | Language determined by browser |
241
-
| optOut | Boolean | Whether to opt the current user out of tracking |`false`|
242
-
| platform | String | Custom platform to set |`'Web'`|
243
-
| savedMaxCount | Number | Maximum number of events to save in localStorage. If more events are logged while offline, old events are removed. | 1000 |
244
-
| saveEvents | Boolean | If `true`, saves events to localStorage and removes them upon successful upload.<br><i>NOTE:</i> Without saving events, events may be lost if the user navigates to another page before events are uploaded. |`true`|
245
-
| sessionTimeout | Number | Time between logged events before a new session starts in milliseconds | 30\*60\*1000 (30 min) |
246
-
| uploadBatchSize | Number | Maximum number of events to send to the server per request. | 100 |
| batchEvents | boolean | If `true`, events are batched together and uploaded only when the number of unsent events is greater than or equal to `eventUploadThreshold` or after `eventUploadPeriodMillis` milliseconds have passed since the first unsent event was logged. | `false` |
250
+
| cookieExpiration | number | The number of days after which the Amplitude cookie will expire | 365\*10 (10 years) |
251
+
| cookieName | string | Custom name for the Amplitude cookie | 'amplitude_id' |
252
+
| deviceId | string | Custom device ID to set. Note this is not recommended unless you really know what you are doing (like if you have your own system for tracking user devices) | Randomly generated UUID |
253
+
| domain | string | Custom cookie domain | The top domain of the current page's url |
254
+
| eventUploadPeriodMillis | number | Amount of time in milliseconds that the SDK waits before uploading events if`batchEvents` is `true`. |30\*1000 (30 sec) |
255
+
| eventUploadThreshold | number | Minimum number of events to batch together per request if`batchEvents` is `true`. |30|
256
+
| includeReferrer | boolean | If `true`, captures the `referrer` and `referring_domain`for each session, as well as the user's `initial_referrer` and `initial_referring_domain` via a set once operation. | `false` |
257
+
| includeUtm | boolean | If `true`, finds utm parameters in the query string or the __utmz cookie, parses, and includes them as user propeties on all events uploaded. | `false` |
258
+
| language | string | Custom language to set | Language determined by browser |
259
+
| optOut | boolean | Whether to disable tracking for the current user | `false` |
260
+
| platform | string | Custom platform to set | 'Web' |
261
+
| saveEvents | boolean | If `true`, saves events to localStorage and removes them upon successful upload.<br><i>NOTE:</i> Without saving events, events may be lost if the user navigates to another page before events are uploaded. | `true` |
262
+
| savedMaxCount | number | Maximum number of events to save in localStorage. If more events are logged while offline, old events are removed. | 1000 |
263
+
| sessionTimeout | number | Time between logged events before a new session starts in milliseconds | 30\*60\*1000 (30 min) |
264
+
| uploadBatchSize | number | Maximum number of events to send to the server per request. | 100 |
248
265
249
266
# Advanced #
250
267
This SDK automatically grabs useful data about the browser, including browser type and operating system version.
@@ -344,7 +361,7 @@ If you are using [RequireJS](http://requirejs.org/) to load your Javascript file
0 commit comments