Skip to content

Commit 7225421

Browse files
authored
Merge pull request #3060 from segmentio/Update-Callback-Timeout-Info
Update Callback Timeout Info
2 parents 0d803c7 + 6b96936 commit 7225421

File tree

1 file changed

+25
-25
lines changed
  • src/connections/sources/catalog/libraries/website/javascript

1 file changed

+25
-25
lines changed

src/connections/sources/catalog/libraries/website/javascript/index.md

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ Field | | Type | Description
7676
`userId` | optional | String | The database ID for the user. If you don't know who the user is yet, you can omit the `userId` and just record `traits`. You can read more about identities in the [identify reference](/docs/connections/spec/identify).
7777
`traits` | optional | Object | A dictionary of traits you know about the user, like `email` or `name`. You can read more about traits in the [identify reference](/docs/connections/spec/identify/).
7878
`options` | optional | Object | A dictionary of options. For example, [enable or disable specific destinations](#managing-data-flow-with-the-integrations-object) for the call. _Note: If you do not pass a `traits` object, pass an empty object (as an '{}') before `options`._
79-
`callback` | optional | Function | A function executed after a short timeout, giving the browser time to make outbound requests first.
79+
`callback` | optional | Function | A function executed after a timeout of 300 ms, giving the browser time to make outbound requests first.
8080

8181
By default, Analytics.js caches traits in the browser's `localStorage` and attaches them to each Identify call.
8282

@@ -126,7 +126,7 @@ Field | | Type | Description
126126
`event`| | String | The name of the event you're tracking. You can read more about the [track method](/docs/connections/spec/track) and recommended event names.
127127
`properties` | optional | Object | A dictionary of [properties](/docs/connections/spec/track#properties) for the event. If the event was `'Added to Cart'`, it might have properties like `price` and `productType`.
128128
`options` | optional | Object | A dictionary of options. For example, [enable or disable specific destinations](#managing-data-flow-with-the-integrations-object) for the call. _Note: If you do not pass a `properties` object, pass an empty object (like '{}') before `options`_.
129-
`callback` | optional | Function | A function that runs after a short timeout, giving the browser time to make outbound requests first.
129+
`callback` | optional | Function | A function that runs after a timeout of 300 ms, giving the browser time to make outbound requests first.
130130

131131
The only required argument in Analytics.js is an _event name string_. You can read more about [how Segment recommends you name events](/docs/connections/spec/track#event).
132132

@@ -139,15 +139,15 @@ analytics.track('Article Completed', {
139139
});
140140
```
141141

142-
For more information about choosing which events to track, event naming and more, check out [Analytics Academy](https://segment.com/academy/).
142+
For more information about choosing which events to track, event naming, and more, check out [Analytics Academy](https://segment.com/academy/){:target="_blank"}.
143143

144144
The only required argument on Track calls in Analytics.js is an `event` name string. Read more about how Segment recommends [naming your events](/docs/connections/spec/track#event).
145145

146146

147147
#### Track Link
148148

149149
`trackLink` is a helper method that attaches the `track` call as a handler to a link.
150-
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.
150+
With `trackLink`, Analytics.js inserts a timeout of 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.
151151

152152
The `trackLink` method follows the format below.
153153

@@ -174,7 +174,7 @@ analytics.trackLink(link, 'Clicked Free-Trial Link', {
174174
#### Track Form
175175

176176
`trackForm` is a helper method that binds a `track` call to a form submission.
177-
The `trackForm` method inserts a short timeout (300 ms) to give the `track` call more time to complete. This is useful to prevent a page from redirecting before the `track` method could complete all requests.
177+
The `trackForm` method inserts a timeout of 300 ms to give the `track` call more time to complete. This is useful to prevent a page from redirecting before the `track` method could complete all requests.
178178

179179
The `trackForm` method follows the format below.
180180

@@ -222,7 +222,7 @@ Field | | Type | Description
222222
`name` | optional | String | The name of the page.
223223
`properties` | optional | Object | 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`.
224224
`options` | optional | Object | A dictionary of options. For example, [enable or disable specific destinations](#managing-data-flow-with-the-integrations-object) for the call. _Note: If you do not pass a `properties` object, pass an empty object (like '{}') before `options`_.
225-
`callback` | optional | Function | A function that runs after a short timeout, giving the browser time to make outbound requests first.
225+
`callback` | optional | Function | A function that runs after a timeout of 300 ms, giving the browser time to make outbound requests first.
226226

227227
#### Default Page Properties
228228

@@ -266,7 +266,7 @@ analytics.page('Pricing', {
266266

267267
The Group method associates an [identified user](/docs/connections/sources/catalog/libraries/website/javascript/#identify) with a company, organization, project, workspace, team, tribe, platoon, assemblage, cluster, troop, gang, party, society or any other collective noun you come up with for the same concept.
268268

269-
This is useful for <!-- Business-to-Business (B2B) -->tools like [Intercom](/docs/connections/destinations/catalog/intercom/), [Preact](/docs/connections/destinations/catalog/preact/) and [Totango](/docs/connections/destinations/catalog/totango/), as it ties the user to a **group** of other users.
269+
This is useful for <!-- Business-to-Business (B2B) -->tools like [Intercom](/docs/connections/destinations/catalog/intercom/), [Preact](/docs/connections/destinations/catalog/preact/), and [Totango](/docs/connections/destinations/catalog/totango/), as it ties the user to a **group** of other users.
270270

271271

272272
The Group method follows the format below.
@@ -281,7 +281,7 @@ Field | | Type | Description
281281
`groupId` | | String | The Group ID to associate with the current user.
282282
`traits` | optional | Object | A dictionary of [traits](/docs/connections/spec/group#traits) for the group. Example traits for a group include `address`, `website`, and `employees`.
283283
`options` | optional | Object | A dictionary of options. For example, [enable or disable specific destinations](#managing-data-flow-with-the-integrations-object) for the call. _Note: If you do not pass a `properties` object, pass an empty object (like '{}') before `options`_.
284-
`callback` | optional | Function | A function that runs after a short timeout, giving the browser time to make outbound requests first.
284+
`callback` | optional | Function | A function that runs after a timeout of 300 ms, giving the browser time to make outbound requests first.
285285

286286
Example `group` call:
287287

@@ -302,7 +302,7 @@ Find more details about `group`, including the `group` payload, in [the Group Sp
302302

303303
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.
304304

305-
This is an advanced method, but it is required to manage user identities successfully in *some* Segment destinations like [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?-->
305+
This is an advanced method, but it's required to manage user identities successfully in *some* Segment destinations like [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?-->
306306

307307
The Alias method follows the format below:
308308

@@ -317,7 +317,7 @@ Field | | Type | Description
317317
`userId` | | String | The new user ID you want to associate with the user.
318318
`previousId` | optional | String | The previous ID that the user was recognized by. This defaults to the currently identified user's ID.
319319
`options` | optional | Object | A dictionary of options. For example, [enable or disable specific destinations](#managing-data-flow-with-the-integrations-object) for the call.
320-
`callback` | optional | Function | A function that is executed after a short timeout, giving the browser time to make outbound requests first.
320+
`callback` | optional | Function | A function that is executed after a timeout of 300 ms, giving the browser time to make outbound requests first.
321321

322322
For more details about Alias, including the **`alias` call payload**, check out the [Segment Spec](/docs/connections/spec/alias/).
323323

@@ -334,9 +334,9 @@ The Analytics.js utility methods help you change how Segment loads on your page.
334334

335335
### Ready
336336

337-
The `ready` method allows you to pass in a method that is called once Analytics.js finishes initializing, and once all enabled device-mode destinations load. It's like [jQuery's `ready` method](https://api.jquery.com/ready/), except for Destinations.
337+
The `ready` method allows you to pass in a method that is called once Analytics.js finishes initializing, and once all enabled device-mode destinations load. It's like [jQuery's `ready` method](https://api.jquery.com/ready/){:target="_blank"}, except for Destinations.
338338

339-
The `ready` method is not invoked if any Destination throws an error (for example, for an expired API key, incorrect settings configuration, or when a Destination is blocked by the browser) during initialization.
339+
The `ready` method isn't invoked if any Destination throws an error (for example, for an expired API key, incorrect settings configuration, or when a Destination is blocked by the browser) during initialization.
340340

341341
The code in the `ready` function only executes after `ready` is emitted.
342342

@@ -378,9 +378,9 @@ analytics.debug(false);
378378

379379
### Emitter
380380

381-
The global `analytics` object emits events whenever you call `alias`, `group`, `identify`, `track` or `page`.
381+
The global `analytics` object emits events whenever you call `alias`, `group`, `identify`, `track`, or `page`.
382382

383-
Use the `on` method to set listeners for these events and run your own custom code. This can be useful if you want to send data to a service for which Segment does not have a destination.
383+
Use the `on` method to set listeners for these events and run your own custom code. This can be useful if you want to send data to a service for which Segment doesn't have a destination.
384384

385385
```js
386386
analytics.on(method, callback);
@@ -411,14 +411,14 @@ This method emits events _before_ they are processed by the Segment integration,
411411

412412
The `timeout` method sets the length (in milliseconds) of callbacks and helper functions. This is useful if you have multiple scripts that need to fire in your callback or `trackLink`, `trackForm` helper function.
413413

414-
The example below sets the timeout to 500ms.
414+
The example below sets the timeout to 500 ms.
415415

416416
```js
417417
analytics.timeout(500);
418418
```
419419

420420
> success "Tip"
421-
> If you're triggering ad network conversion pixels, Segment recommends extending timeout to 500ms to account for slow load times.
421+
> If you're triggering ad network conversion pixels, Segment recommends extending timeout to 500 ms to account for slow load times.
422422
423423

424424
### Reset or Logout
@@ -429,9 +429,9 @@ Calling `reset` resets the `id`, including `anonymousId`, and clears `traits` fo
429429
analytics.reset();
430430
```
431431

432-
The `reset` method only clears the cookies and `localStorage` created by Segment. It does not clear data from other integrated tools, as those native libraries might set their own cookies to manage user tracking, sessions, and manage state. To completely clear out the user session, see the documentation provided by those tools.
432+
The `reset` method only clears the cookies and `localStorage` created by Segment. It doesn't clear data from other integrated tools, as those native libraries might set their own cookies to manage user tracking, sessions, and manage state. To completely clear out the user session, see the documentation provided by those tools.
433433

434-
Segment does not share `localStorage` across subdomains. If you use Segment tracking on multiple subdomains, you must call `analytics.reset()` for each subdomain to completely clear out the user session.
434+
Segment doesn't share `localStorage` across subdomains. If you use Segment tracking on multiple subdomains, you must call `analytics.reset()` for each subdomain to completely clear out the user session.
435435

436436

437437

@@ -473,7 +473,7 @@ analytics.identify('user_123', {
473473
});
474474
```
475475

476-
You don't need to include `'All': true` in this call because it is implied as the default behavior. Instead, only list the destinations that you want to exclude, with a `false` flag for each.
476+
You don't need to include `'All': true` in this call because it's implied as the default behavior. Instead, only list the destinations that you want to exclude, with a `false` flag for each.
477477

478478
Destination flags are **case sensitive** and match [the destination's name in the docs](/docs/connections/destinations/) (for example, "AdLearn Open Platform", "awe.sm", "Mailchimp", etc). If a Destination has more than one acceptable name, this appears in the documentation for that destination.
479479

@@ -488,7 +488,7 @@ Destination flags are **case sensitive** and match [the destination's name in th
488488
489489
You can modify the `.load` method in Analytics.js (the second line of the snippet) to take a second argument. If you pass an object with an `integrations` dictionary (matching the format [above](#selecting-destinations-with-the-integrations-object)), then Segment only loads the integrations in that dictionary that are marked as enabled with the boolean value `true`.
490490

491-
You can only call `.load` on page load, or reload (refresh). If you modify the `.load` method between page loads, it does not have any effect until the page is reloaded.
491+
You can only call `.load` on page load, or reload (refresh). If you modify the `.load` method between page loads, it doesn't have any effect until the page is reloaded.
492492

493493
For example:
494494

@@ -570,7 +570,7 @@ Upon receiving the `beforeunload` browser event, Analytics.js attempts to flush
570570
No. Batching is only supported as part of Analytics.js 2.0.
571571

572572
#### Can other destinations receive batched events?
573-
No, this batching only impacts events sent to Segment. Once the batch reaches Segment, it is split up and follows the normal path of an event.
573+
No, this batching only impacts events sent to Segment. Once the batch reaches Segment, it's split up and follows the normal path of an event.
574574

575575
#### Will batching impact billing or throughput?
576576
No, batching won't impact billing or throughput.
@@ -732,13 +732,13 @@ Analytics.js tracks across subdomains out of the box; all Segment destinations f
732732

733733
## Analytics.js Performance
734734

735-
The Analytics.js library and all Destination libraries are loaded with the [HTML script `async` tag](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/script#attr-async). This also means that Segment fires methods asynchronously, so you should adjust your code accordingly if you require that events be sent from the browser in a specific order.
735+
The Analytics.js library and all Destination libraries are loaded with the [HTML script `async` tag](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/script#attr-async){:target="_blank"}. This also means that Segment fires methods asynchronously, so you should adjust your code accordingly if you require that events be sent from the browser in a specific order.
736736

737-
While many tools require access to the DOM or cookies, for the Zendesk, Salesforce, and Mailchimp destinations, Segment does not need to load a native JavaScript library. Instead, Segment's servers send data to the end-tools.
737+
While many tools require access to the DOM or cookies, for the Zendesk, Salesforce, and Mailchimp destinations, Segment doesn't need to load a native JavaScript library. Instead, Segment's servers send data to the end-tools.
738738

739739
Segment loads the libraries required for your **enabled** Destinations. When you disable a destination, the custom version of Analytics.js loaded on your site stops requesting that library.
740740

741-
Using Analytics.js does not offer a large performance benefit, but is more performant than installing each of the destinations individually. And as more destinations move to accept data directly from Segment, you'll receive more performance benefits automatically.
741+
Using Analytics.js doesn't offer a large performance benefit, but is more performant than installing each of the destinations individually. And as more destinations move to accept data directly from Segment, you'll receive more performance benefits automatically.
742742

743743
One option, if you don't want to use any bundled third-party tools, is to use the browserify'd [analytics-node](https://github.com/segmentio/analytics-node) package. <!-- TODO LR note: WTF does "browserified" mean-->
744744

@@ -757,7 +757,7 @@ Analytics.js uses `localstorage` cookies if you have retries enabled, to keep tr
757757
- The `reclaimStart` and `reclaimEnd` cookies determine if a tab takes over the queue from another tab.
758758
- The `inProgress` and `queue` cookies track events in progress, and events queued for retry.
759759

760-
For more information, visit the [Segment localstorage-retry library](https://github.com/segmentio/localstorage-retry).
760+
For more information, visit the [Segment localstorage-retry library](https://github.com/segmentio/localstorage-retry){:target="_blank"}.
761761

762762
You can set the `debug` cookie to `analytics.js` to log debug messages from Analytics.js to the console.
763763

0 commit comments

Comments
 (0)