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
+9-4Lines changed: 9 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,9 +1,14 @@
1
1
## Unreleased
2
2
3
-
* Add support for passing callback function to identify.
4
-
* Add support for prepend user property operation.
5
-
* Keep sessions and event metadata in sync across multiple windows/tabs.
6
-
* Add support for setting groups for users and events.
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 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.
6
+
7
+
### 2.10.0 (March 30, 2016)
8
+
9
+
* Identify function now accepts a callback function as an argument. The callback will be run after the identify event is sent.
10
+
* Add support for `prepend` user property operation. This allows you to insert value(s) at the front of a list. See [Readme](https://github.com/amplitude/Amplitude-Javascript#user-properties-and-user-property-operations) for more details.
11
+
* Keep sessions and event metadata in-sync across multiple windows/tabs.
Copy file name to clipboardExpand all lines: README.md
+25-16Lines changed: 25 additions & 16 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -3,14 +3,16 @@
3
3
Amplitude-Javascript
4
4
====================
5
5
6
+
This Readme will guide you through using Amplitude's Javascript SDK to track users and events. See our [SDK documentation](https://rawgit.com/amplitude/Amplitude-Javascript/master/documentation/Amplitude.html) for a description of all available SDK methods.
7
+
6
8
# Setup #
7
9
1. If you haven't already, go to http://amplitude.com and register for an account. You will receive an API Key.
8
10
2. On every page that uses analytics, paste the following Javascript code between the `<head>` and `</head>` tags:
| saveEvents | 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`|
230
-
| savedMaxCount | Maximum number of events to save in localStorage. If more events are logged while offline, old events are removed. | 1000 |
231
-
| uploadBatchSize | Maximum number of events to send to the server per request. | 100 |
232
-
| includeUtm | 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`|
233
-
| includeReferrer | 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`|
234
-
| batchEvents | 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`|
235
-
| eventUploadThreshold | Minimum number of events to batch together per request if `batchEvents` is `true`. | 30 |
236
-
| eventUploadPeriodMillis | Amount of time in milliseconds that the SDK waits before uploading events if `batchEvents` is `true`. | 30\*1000 (30 sec) |
237
-
| deviceId | Custom device ID to set | Randomly generated UUID |
238
-
| sessionTimeout | Time between logged events before a new session starts in milliseconds | 30\*60\*1000 (30 min) |
231
+
| 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 |
247
+
239
248
240
249
# Advanced #
241
250
This SDK automatically grabs useful data about the browser, including browser type and operating system version.
@@ -246,14 +255,14 @@ Amplitude supports assigning users to groups, and performing queries such as cou
246
255
247
256
In the above example, 'orgId' is a `groupType`, and the value 10 or 15 is the `groupName`. Another example of a `groupType` could a sport that the user participates in, and possible `groupNames` within that type would be tennis, baseball, etc.
248
257
249
-
You can use `setGroup(groupType, groupName)` to designate which groups a user belongs to. Few things to note: this will also set the `groupType: groupName` as a user property. **This will overwrite any existing groupName value set for that user's groupType, as well as the corresponding user property value.** For example if Joe was in orgId 10, and you call `setGroup('orgId', 20)`, 20 would replace 10. You can also call `setGroup` multiple times with different groupTypes to add a user to different groups. For example Sue is in orgId: 15, and she also plays sport: soccer. Now when querying, you can Count By both orgId and sport. **You are allowed to set up to 5 different groupTypes per user.** Any more than that will be ignored from the query UI, although they will still appear as user properties.
258
+
You can use `setGroup(groupType, groupName)` to designate which groups a user belongs to. Few things to note: this will also set the `groupType: groupName` as a user property. **This will overwrite any existing groupName value set for that user's groupType, as well as the corresponding user property value.** For example if Joe was in orgId 10, and you call `setGroup('orgId', 20)`, 20 would replace 10. You can also call `setGroup` multiple times with different groupTypes to add a user to different groups. For example Sue can be in orgId: 15, and she also plays sport: soccer. Now when querying, you can Count By both orgId and sport (although as separate queries). **You are allowed to set up to 5 different groupTypes per user.** Any more than that will be ignored from the Count By Distinct query UI, although they will still appear as user properties for that user.
250
259
251
260
```javascript
252
261
amplitude.setGroup('orgId', 15);
253
262
amplitude.setGroup('sport', 'tennis');
254
263
```
255
264
256
-
You can also use `logEventWithGroups` to set event-level groups, meaning the group designation only applies for the specific event being logged and does not persist on the user unless you explicitly set it with `setGroup`.
265
+
You can also use `logEventWithGroups` to set event-level groups, meaning the group designation only applies for the specific event being logged and does not persist on the user (unless you explicitly set it with `setGroup`).
257
266
258
267
```javascript
259
268
var eventProperties = {
@@ -335,7 +344,7 @@ If you are using [RequireJS](http://requirejs.org/) to load your Javascript file
0 commit comments