Skip to content

Commit 75879ba

Browse files
authored
Merge branch 'master' into develop
2 parents 01998a9 + 5dcec5b commit 75879ba

File tree

1 file changed

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

1 file changed

+11
-0
lines changed

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

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -919,6 +919,17 @@ To minimize client-side data loss, Segment provides a few workarounds. However,
919919
920920
* Consider using one of Segment’s [server-side libraries](/docs/connections/sources/#server). Using a server-side library eliminates concerns about tracking blockers and privacy browsers that can prevent Segment from loading. This option may require additional code to track actions like a Page call, as you now need to manually pass contextual information that would have been automatically collected by Analytics.js, like `url`, `path`, and `referrer`. Note that some destinations are device-mode only.
921921
922+
## Installing the library under a custom global namespace
923+
924+
When you load Analytics.js through snippet code, by default, the SDK installs on `window.analytics` global variable. If this causes a conflict with another library on your page, you can change the global variable used by Analytics.js if you use snippet version 5.2.1 or later.
925+
926+
Change the global variable in the beginning of your snippet code as shown below. In this case, Analytics.js uses `window.custom_key` to load instead of `window.analytics`.
927+
928+
```diff
929+
- !function(){var i="analytics", ...
930+
+ !function(){var i="custom_key", ...
931+
```
932+
922933
## Add destinations from npm
923934
924935
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.

0 commit comments

Comments
 (0)