|
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. You can also take a look at the [SDK documentation](https://rawgit.com/amplitude/Amplitude-Javascript/defensive_cleanup/documentation/Amplitude.html). |
| 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:
|
@@ -224,18 +226,25 @@ amplitude.init('YOUR_API_KEY_HERE', null, {
|
224 | 226 | });
|
225 | 227 | ```
|
226 | 228 |
|
227 |
| -| option | description | default | |
| 229 | +| option | type | description | default | |
228 | 230 | |------------|----------------------------------------------------------------------------------|-----------|
|
229 |
| -| 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.
|
|
0 commit comments