Skip to content

Commit 1b5665b

Browse files
committed
update settings
1 parent 7cdc6d4 commit 1b5665b

File tree

1 file changed

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

1 file changed

+44
-9
lines changed

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

Lines changed: 44 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -328,7 +328,6 @@ The Analytics.js utility methods help you change how Segment loads on your page.
328328
- [On (Emitter)](#emitter)
329329
- [Timeout](#extending-timeout)
330330
- [Reset (Logout)](#reset-or-log-out)
331-
- [Keepalive](#keepalive)
332331

333332
### Load
334333

@@ -372,7 +371,7 @@ If you want to access end-tool library methods that do not match any Analytics.j
372371

373372

374373
```js
375-
analytics.ready(function() {
374+
analytics.ready(() => {
376375
window.mixpanel.set_config({ verbose: true });
377376
});
378377
```
@@ -422,7 +421,7 @@ analytics.on(method, callback);
422421
Example:
423422

424423
```js
425-
analytics.on('track', function(event, properties, options) {
424+
analytics.on('track', (event, properties, options) => {
426425

427426
bigdataTool.push(['recordEvent', event]);
428427

@@ -461,11 +460,6 @@ The `reset` method only clears the cookies and `localStorage` created by Segment
461460

462461
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.
463462

464-
### Keepalive
465-
466-
You can utilize this in instances where an API call fires on a hard redirect, and are missed from getting captured in Segment. If you set this flag to true, it enables firing the event before the redirect. This is available for all events. You can read more about this in the [Github PR](https://github.com/segmentio/analytics-next/issues/768#issuecomment-1386100830){:target="_blank"}.
467-
468-
469463
## Managing data flow with the Integrations object
470464

471465
> success ""
@@ -530,7 +524,7 @@ analytics.load('writekey', { integrations: { All: false, 'Google Analytics': tru
530524
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.
531525

532526
```js
533-
onConsentDialogClosed(function(consentedTools){
527+
onConsentDialogClosed((consentedTools) => {
534528
analytics.load('writekey', { integrations: consentedTools })
535529
})
536530
```
@@ -589,6 +583,47 @@ When enabled, Analytics.js automatically retries network and server errors. With
589583
Analytics.js stores events in `localStorage` and falls back to in-memory storage when `localStorage` is unavailable. It retries up to 10 times with an incrementally increasing back-off time between each retry. Analytics.js queues up to 100 events at a time to avoid using too much of the device's local storage. See the [destination Retries documentation](/docs/connections/destinations/#retries) to learn more.
590584

591585

586+
## Headers
587+
588+
### Add custom headers
589+
You can override your headers by custom
590+
```ts
591+
analytics.load("<YOUR_WRITE_KEY>",
592+
{
593+
integrations: {
594+
'Segment.io': {
595+
deliveryStrategy: {
596+
config: {
597+
headers: { 'x-api-key': 'foo' }
598+
},
599+
},
600+
},
601+
},
602+
}
603+
```
604+
605+
## Keepalive
606+
607+
You can utilize this in instances where an API call fires on a hard redirect, and are missed from getting captured in Segment. If you set this flag to true, it enables firing the event before the redirect.
608+
609+
By default, this is set to `false`. This is because there is a 64kb limit for all fetch requests with keepalive. So when sending keepalive requests, you are competing with other in-flight keepalive requests, regardless of being Segment related requests or not -- which can result in data loss in some scenarios. By default, we only use keep-alive if 1. the page is 'unloading' and 2. the user is using batching.
610+
611+
```ts
612+
analytics.load("<YOUR_WRITE_KEY>",
613+
{
614+
integrations: {
615+
'Segment.io': {
616+
deliveryStrategy: {
617+
config: {
618+
keepalive: true
619+
},
620+
},
621+
},
622+
},
623+
}
624+
```
625+
626+
592627
## Batching
593628
Batching is the ability to group multiple requests or calls into one request or API call. All requests sent within the same batch have the same `receivedAt` time. With Analytics.js, you can send events to Segment in batches. Sending events in batches enables you to have:
594629
- Delivery of multiple events with fewer API calls

0 commit comments

Comments
 (0)