Skip to content

Commit 2142180

Browse files
committed
add Segment.io=true requirement and more cleanup
1 parent 7989494 commit 2142180

File tree

1 file changed

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

1 file changed

+10
-8
lines changed

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

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ The Identify call has the following fields:
7171
| `callback` | optional | Function | A function executed after a timeout of 300 ms, giving the browser time to make outbound requests first. |
7272

7373

74-
If you want to set the `userId` without sending an Identify call, you can use `analytics.user().id('123')`. In the NPM package, use `analytics.instance.user().id(xxx)`. This method updates the stored `userId` locally without triggering a network request. This is helpful if you want to associate a user ID silently, without sending additional data to Segment or connected destinations. Be cautious when changing the `userId` mid-session to avoid double-counting users or splitting their identity history.
74+
If you want to set the `userId` without sending an Identify call, you can use `analytics.user().id('123')`. In the npm package, use `analytics.instance.user().id(xxx)`. This method updates the stored `userId` locally without triggering a network request. This is helpful if you want to associate a user ID silently, without sending additional data to Segment or connected destinations. Be cautious when changing the `userId` mid-session to avoid double-counting users or splitting their identity history.
7575

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

@@ -297,7 +297,7 @@ analytics.group('UNIVAC Working Group', {
297297

298298
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.
299299

300-
Find more details about `group`, including the `group` payload, in [the Group Spec](/docs/connections/spec/group/).
300+
Find more details about the Group method, including the payload, in [the Group Spec](/docs/connections/spec/group/).
301301

302302
### Alias
303303

@@ -337,7 +337,7 @@ The Analytics.js utility methods help you change how Segment loads on your page.
337337
### Load
338338

339339
> info ""
340-
> The Load method is also available when you load analytics.js through the [NPM package](https://www.npmjs.com/package/@segment/analytics-next){:target="_blank"}.
340+
> The Load method is also available when you load analytics.js through the [npm package](https://www.npmjs.com/package/@segment/analytics-next){:target="_blank"}.
341341
342342
You can load a buffered version of analytics.js that requires you to call `load` explicitly before analytics.js initiates any network activity. This is useful if you want to, for example, wait for user consent before you fetch tracking destinations or send buffered events to Segment.
343343

@@ -410,7 +410,7 @@ analytics.debug(false);
410410

411411
### Emitter
412412

413-
The global `analytics` object emits events whenever you call `alias`, `group`, `identify`, `track`, or `page`.
413+
The global `analytics` object emits events whenever you call Alias, Group, Identify, Track, or Page.
414414

415415
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.
416416

@@ -421,7 +421,7 @@ analytics.on(method, callback);
421421
| Field | Type | Description |
422422
| ---------- | -------- | ---------------------------------------------------------------------------------------------------------- |
423423
| `method` | String | Name of the method to listen for. |
424-
| `callback` | Function | A function to execute after each emitted method, taking three arguments: `event`, `properties`, and `options`. |
424+
| `callback` | Function | A function to execute after each emitted method, taking 3 arguments: `event`, `properties`, and `options`. |
425425

426426
Example:
427427

@@ -516,14 +516,16 @@ Destination flags are **case sensitive** and match [the destination's name in th
516516
> info ""
517517
> To use this feature, you must be on snippet version 4.1.0 or later. You can get the latest version of the snippet from the [Analytics.js Quickstart](/docs/connections/sources/catalog/libraries/website/javascript/quickstart/#step-2-copy-the-segment-snippet).
518518
519-
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, then Segment only loads the integrations in that dictionary that are marked as enabled with the boolean value `true`.
519+
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, then Segment only loads the integrations in that dictionary that are marked as enabled with the boolean value `true`.
520520

521521
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.
522522

523+
Note that if you add `All: false` to your Load call, you must also add `Segment.io: true` to the integrations object to pass data to enabled destinations.
524+
523525
For example:
524526

525527
```js
526-
analytics.load('writekey', { integrations: { All: false, 'Google Analytics': true, 'Segment.io': true } })
528+
analytics.load('writekey', { integrations: { All: false, 'Segment.io': true, 'Google Analytics': true } })
527529
```
528530

529531
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.
@@ -653,7 +655,7 @@ Batching is the ability to group multiple requests or calls into one request or
653655
- Fewer errors if a connection is lost because an entire batch will retry at once rather than multiple calls retrying at random times.
654656

655657
### Setup
656-
You can start batching by changing the `strategy` to `"batching"` and the parameters for `size` and `timeout` within the `load` method in the analytics object. Batching requires both parameters.
658+
You can start batching by changing the `strategy` to `"batching"` and the parameters for `size` and `timeout` within the Load method in the analytics object. Batching requires both parameters.
657659

658660
```js
659661
analytics.load("<write_key>", {

0 commit comments

Comments
 (0)