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: src/connections/sources/catalog/libraries/website/javascript/index.md
+22-22Lines changed: 22 additions & 22 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -30,12 +30,12 @@ Analytics.js 2.0 provides a reduction in page load time, which improves site per
30
30
Analytics.js 2.0 introduces new ways for developers to augment events throughout the event timeline. This enables teams to support:
31
31
32
32
- New privacy and consent controls before an event occurs
33
-
- Enriching events with additional customer or page context in-flight using middleware
33
+
- Enriching events with customer or page context in-flight using middleware
34
34
- Collecting better metrics related to deliverability *after* a message is sent
35
35
36
36
## Getting Started
37
37
38
-
Read through the [Analytics.js QuickStart Guide](/docs/connections/sources/catalog/libraries/website/javascript/quickstart/) which explains how to add Analytics.js to your site in just a few minutes. Once you've installed the library, read on for the detailed API reference!
38
+
Read through the [Analytics.js QuickStart Guide](/docs/connections/sources/catalog/libraries/website/javascript/quickstart/) which explains how to add Analytics.js to your site. Once you've installed the library, read on for the detailed API reference!
39
39
40
40
For information about upgrading to Analytics.js 2.0, see [Upgrade to Analytics.js 2.0](/docs/connections/sources/catalog/libraries/website/javascript/upgrade-to-ajs2).
41
41
@@ -57,7 +57,7 @@ These names might be familiar, because they are the basic methods covered by the
57
57
The `identify` method is how you link your users, and their actions, to a recognizable `userId` and `traits`. You can see [an `identify` example in the Quickstart guide](/docs/connections/sources/catalog/libraries/website/javascript/quickstart/#step-3-identify-users) or [find details on the identify method payload](/docs/connections/spec/identify/).
58
58
59
59
> note ""
60
-
> Segment recommends _against_ using `identify` for anonymous visitors to your site. Analytics.js automatically retrieves an `anonymousId` from localStorage or assigns one for new visitors, which is attached to all `page` and `track` events both before and after an `identify`.
60
+
> Segment recommends _against_ using `identify` for anonymous visitors to your site. Analytics.js automatically retrieves an `anonymousId` from localStorage or assigns one for new visitors, and attaches it to all `page` and `track` events both before and after an `identify`.
61
61
62
62
The Identify method follows the format below:
63
63
@@ -95,7 +95,7 @@ The Identify call has the following fields:
95
95
</table>
96
96
97
97
98
-
By default, traits are cached in the browser's `localStorage` and are attached to each subsequent Identify call.
98
+
By default, Analytics.js caches traits in the browser's `localStorage` and are attaches them to each Identify call.
99
99
100
100
For example, you might call Identify when someone signs up for a newsletter, but hasn't yet created an account on your site. The example below shows an Identify call (using hard-coded traits) that you might send in this case.
101
101
```js
@@ -143,7 +143,7 @@ The `track` call has the following fields:
143
143
<td>`event`</td>
144
144
<td></td>
145
145
<td>String</td>
146
-
<td>The name of the event you're tracking. You can read more about the [track method](/docs/connections/spec/track) and what event names we recommend.</td>
146
+
<td>The name of the event you're tracking. You can read more about the [track method](/docs/connections/spec/track) and recommended event names.</td>
147
147
</tr>
148
148
<tr>
149
149
<td>`properties`</td>
@@ -161,7 +161,7 @@ The `track` call has the following fields:
161
161
<td>`callback`</td>
162
162
<td>optional</td>
163
163
<td>Function</td>
164
-
<td>A function that is executed after a short timeout, giving the browser time to make outbound requests first.</td>
164
+
<td>A function that runs after a short timeout, giving the browser time to make outbound requests first.</td>
165
165
</tr>
166
166
</table>
167
167
@@ -184,7 +184,7 @@ The only required argument on Track calls in Analytics.js is an `event` name str
184
184
#### Track Link
185
185
186
186
`trackLink` is a helper method that attaches the `track` call as a handler to a link.
187
-
With `trackLink`a short timeout (300 ms) is inserted to give the `track` call more time. This is useful when a page would redirect before the `track` method could complete all requests.
187
+
With `trackLink`, Analytics.js inserts a short timeout (300 ms) to give the `track` call more time. This is useful when a page would redirect before the `track` method could complete all requests.
<td>DOM element to be bound with `track` method. You may pass an array of elements or jQuery objects. _Note: This must be an element, **not** a CSS selector._</td>
199
+
<td>DOM element to bind with `track` method. You may pass an array of elements or jQuery objects. _Note: This must be an element, **not** a CSS selector._</td>
200
200
</tr>
201
201
<tr>
202
202
<td>`event` </td>
203
203
<td>String or Function</td>
204
-
<td>The name of the event, passed to the `track` method. Or a **function** that returns a string to be used as the name of the `track` event.</td>
204
+
<td>The name of the event, passed to the `track` method. Or a **function** that returns a string to use as the name of the `track` event.</td>
205
205
</tr>
206
206
<tr>
207
207
<td>`properties` optional</td>
208
208
<td>Object or Function</td>
209
-
<td>A dictionary of properties to pass with the track method. Or a **function** that returns an object to be used as the `properties` of the event.</td>
209
+
<td>A dictionary of properties to pass with the track method. Or a **function** that returns an object to use as the `properties` of the event.</td>
<td>The name of the event, passed to the `track` method. Or a **function** that returns a string to be used as the name of the `track` event.</td>
243
+
<td>The name of the event, passed to the `track` method. Or a **function** that returns a string to use as the name of the `track` event.</td>
244
244
</tr>
245
245
<tr>
246
246
<td>`properties` optional</td>
247
247
<td>Object or Function</td>
248
-
<td>A dictionary of properties to pass with the track method. Or a **function** that returns an object to be used as the `properties` of the event.</td>
248
+
<td>A dictionary of properties to pass with the track method. Or a **function** that returns an object to use as the `properties` of the event.</td>
The [Page](/docs/connections/spec/page/) method lets you record page views on your website, along with optional extra information about the page being viewed.
265
+
The [Page](/docs/connections/spec/page/) method lets you record page views on your website, along with optional extra information about the page viewed by the user.
266
266
267
267
Because some destinations require a `page` call to instantiate their libraries, **you must call `page`** at least once per page load. You can call it more than once if needed, for example on virtual page changes in a single page app.
268
268
269
-
A Page call is included by default as the final line in [the Analytics.js snippet](/docs/connections/sources/catalog/libraries/website/javascript/quickstart/#step-2-copy-the-segment-snippet). You can modify this `page` call within the guidelines below.
269
+
Analytics.js includes a Page call by default as the final line in [the Analytics.js snippet](/docs/connections/sources/catalog/libraries/website/javascript/quickstart/#step-2-copy-the-segment-snippet). You can update this `page` call within the guidelines below.
270
270
271
271
The `page` method follows the format below.
272
272
@@ -293,7 +293,7 @@ The `page` call has the following fields:
293
293
<td>`properties`</td>
294
294
<td>optional</td>
295
295
<td> Object </td>
296
-
<td>A dictionary of properties of the page. Note: `url`, `title`, `referrer` and `path` are collected automatically! Additionally this defaults to a `canonical url`, if available, and falls back to `document.location.href`.</td>
296
+
<td>A dictionary of properties of the page. Note: Analytics.js collects `url`, `title`, `referrer` and `path` are automatically. This defaults to a `canonical url`, if available, and falls back to `document.location.href`.</td>
297
297
</tr>
298
298
<tr>
299
299
<td>`options`</td>
@@ -305,20 +305,20 @@ The `page` call has the following fields:
305
305
<td>`callback`</td>
306
306
<td>optional</td>
307
307
<td>Function</td>
308
-
<td>A function that is executed after a short timeout, giving the browser time to make outbound requests first.</td>
308
+
<td>A function that runs after a short timeout, giving the browser time to make outbound requests first.</td>
309
309
</tr>
310
310
</table>
311
311
312
312
313
313
#### Default Page Properties
314
314
315
-
A few properties are automatically added to each `page` call.
315
+
Analytics.js adds some properties to each `page` call.
316
316
317
317
```js
318
318
analytics.page('Pricing');
319
319
```
320
320
321
-
Segment adds the following information without any extra work from you:
321
+
Segment adds the following information:
322
322
323
323
```js
324
324
analytics.page('Pricing', {
@@ -385,7 +385,7 @@ The Group call has the following fields:
385
385
<td>`callback`</td>
386
386
<td>optional</td>
387
387
<td>Function</td>
388
-
<td>A function that is executed after a short timeout, giving the browser time to make outbound requests first.</td>
388
+
<td>A function that runs after a short timeout, giving the browser time to make outbound requests first.</td>
389
389
</tr>
390
390
</table>
391
391
@@ -401,13 +401,13 @@ analytics.group('UNIVAC Working Group', {
401
401
});
402
402
```
403
403
404
-
By default, group `traits`are cached in the browser's local storage and attached to each subsequent`group` call, similar to how the `identify` method works.
404
+
By default, Analytics.js caches group `traits` in the browser's local storage and attaches them to each `group` call, similar to how the `identify` method works.
405
405
406
406
Find more details about `group` including the **`group` payload** in [the Group Spec](/docs/connections/spec/group/).
407
407
408
408
### Alias
409
409
410
-
The Alias method combines two previously unassociated user identities. Segment usually handles aliasing automatically when you call Identify on a user, however some tools require an explicit `alias` call.
410
+
The Alias method combines two unassociated user identities. Segment usually handles aliasing automatically when you call Identify on a user, however some tools require an explicit `alias` call.
411
411
412
412
This is an advanced method, but it is required to manage user identities successfully in *some* of our destinations such as [Kissmetrics](/docs/connections/destinations/catalog/kissmetrics/#alias) and [Mixpanel](/docs/connections/destinations/catalog/mixpanel/#alias). <!-- TODO: LR Dests question: is this still true? Is there a list of the ones that require this?-->
> **Note:** To use this feature, you must be on snippet version 4.1.0 or later. You can get the latest version of the snippet [here](https://segment.com/docs/connections/sources/catalog/libraries/website/javascript/quickstart/#step-2-copy-the-segment-snippet).
636
+
> **Note:** To use this feature, you must be on snippet version 4.1.0 or later. You can get the latest version of the snippet [here](/docs/connections/sources/catalog/libraries/website/javascript/quickstart/#step-2-copy-the-segment-snippet).
637
637
638
638
This way, you can conditionally load integrations based on what customers opt into on your site. The example below shows how you might load only the tools that the user agreed to use.
0 commit comments