Skip to content

Commit 961fc59

Browse files
authored
Merge pull request #5315 from segmentio/DOC-727
add destinations from npm
2 parents 776f7e3 + 466b78e commit 961fc59

File tree

1 file changed

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

1 file changed

+32
-0
lines changed

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

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -887,6 +887,38 @@ If the above routes don't work, Segment provides these workarounds to help with
887887

888888
* Consider tracking data using one of Segment's [server-side libraries](/docs/connections/sources/#server). By using a server-side library, you no longer have to worry about ad blockers and privacy browsers preventing Segment from loading. This option may require more code to track something like a `.page()` call, since now you have to manually pass contextual information that otherwise would've been collected automatically by Analytics.js, such as `url`, `path`, `referrer`. Note that some destinations are device-mode only.
889889

890+
## Add destinations from npm
891+
892+
Bundle the destinations you want loaded from [npm](https://www.npmjs.com/package/@segment/analytics-next){:target="_blank"} instead of having them loaded from a remote CDN. This enables you to have fewer network requests when adding destinations.
893+
894+
* To add actions-based destinations from npm:
895+
896+
```js
897+
import vwo from '@segment/analytics-browser-actions-vwo'
898+
import braze from '@segment/analytics-browser-actions-braze'
899+
900+
const analytics = AnalyticsBrowser.load({
901+
writeKey: '<WRITE_KEY>',
902+
plugins: [vwo, braze],
903+
})
904+
```
905+
906+
Pass in the destination plugin to the added config option called `plugins`. A list of all action destination packages can be found [here](https://github.com/segmentio/action-destinations/blob/main/packages/destinations-manifest/package.json){:target="_blank"}.
907+
908+
909+
* To add classic destinations from npm:
910+
911+
```js
912+
import { AnalyticsBrowser } from '@segment/analytics-next'
913+
import GoogleAnalyticsIntegration from '@segment/analytics.js-integration-google-analytics'
914+
915+
// The following example assumes configuration for Google Analytics will be available in the fetched settings
916+
const analytics = AnalyticsBrowser.load({
917+
writeKey: '<WRITE_KEY>',
918+
classicIntegrations: [ GoogleAnalyticsIntegration ]
919+
}),
920+
```
921+
890922
## Open source libraries
891923

892924
Analytics.js 2.0 includes the following open source components:

0 commit comments

Comments
 (0)