You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/connections/sources/catalog/libraries/website/javascript/troubleshooting.md
+17-2Lines changed: 17 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -22,16 +22,30 @@ Segment also provides a Chrome web extension, [Segment Inspector](/docs/connecti
22
22
23
23
To learn more, follow the [Analytics.js Quickstart Guide](/docs/connections/sources/catalog/libraries/website/javascript/quickstart/).
24
24
25
-
## Are you loading two instances of Analytics.js?
25
+
## Loading multiple instances of Analytics.js
26
26
27
-
Note that you *cannot* load Analytics.js twice on the same page, even if you're using different write keys. If you do, you might encounter `Uncaught RangeError: Maximum call stack size exceeded`. Instead, you can conditionally set the write key based on an environment variable.
27
+
28
+
### Analytics.js snippet loaded more than once
29
+
30
+
You cannot load the Analytics.js snippet twice on the same page, even if different write keys are used. Doing so might result in errors like `Uncaught RangeError: Maximum call stack size exceeded`.
31
+
32
+
However, you can conditionally set the write key based on an environment variable:
28
33
29
34
Example:
30
35
```js
31
36
var writeKey;
32
37
ENV==='production'? writeKey ='A': writeKey ='B';
33
38
```
34
39
40
+
### Multiple Versions of Analytics.js
41
+
42
+
You can load multiple versions of Analytics.js in the same environment. For example, you could have both a snippet version and an npm version on one page, each with different write keys. This allows the npm library and the browser snippet to coexist without conflicting.
43
+
44
+
Keep the following limitations in mind:
45
+
46
+
-**Device-Mode Destination Conflicts**: If you are using the same device-mode destination in both instances (for example, across different write keys), conflicts may occur. This is due to third-party scripts that don't support global instances. To avoid issues, ensure you are not using the same device-mode destination with different write keys.
47
+
-**CDN URL Customization:** Segment does not support overriding the CDNURL when using multiple instances of Analytics.js.
48
+
35
49
## How do I resolve the 'Failed to Load Analytics.js ChunkLoadError'?
36
50
37
51
The error can occur for different reasons:
@@ -44,6 +58,7 @@ The error can occur for different reasons:
44
58
45
59
- Cloudflare caching: If you use Cloudflare to proxy Segment, disable caching for the Segment JS file.
46
60
61
+
47
62
## Do you see events appear in your debugger?
48
63
49
64
When you reload the page, does your debugger show a new [Page call](/docs/connections/spec/page)? You can also check the JavaScript console in the browser and manually fire an event, like an Identify call, which would show up in the debugger.
0 commit comments