Skip to content

Commit c60ce06

Browse files
Update troubleshooting.md
1 parent fa9b96a commit c60ce06

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

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

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,16 +20,26 @@ Segment also provides a Chrome web extension, [Segment Inspector](/docs/connecti
2020

2121
Solution: [Follow the Analytics.js Quickstart Guide](/docs/connections/sources/catalog/libraries/website/javascript/quickstart/)
2222

23-
## Are you loading two instances of Analytics.js?
23+
## Loading Multiple Instances of Analytics.js
2424

25-
Note that you *cannot* load Analytics.js twice on the same page, even if you're using different write keys. You might encounter `Uncaught RangeError: Maximum call stack size exceeded`. You can conditionally set the write key based on an environment variable.
25+
### Analytics.js Snippet Loaded More Than Once
26+
27+
It is not possible to load the Analytics.js snippet twice on the same page, even if different write keys are used. Doing so often results in errors like `Uncaught RangeError: Maximum call stack size exceeded`. However, you can conditionally set the write key based on an environment variable:
2628

2729
Example:
2830
```js
2931
var writeKey;
3032
ENV === 'production' ? writeKey = 'A' : writeKey = 'B';
3133
```
3234

35+
### Multiple Versions of Analytics.js
36+
37+
It is possible to load multiple versions of Analytics.js, such as a snippet version and an npm version (with different writekeys), in the same environment without them interfering with each other. This allows the npm library and the browser snippet to coexist without conflicting.Just keep in mind the following limitations with this approach:
38+
39+
**1. Device-Mode Destination Conflicts**: If you are using the same device-mode destination in both instances (i.e., across different writekeys), 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 between different write keys.
40+
41+
**2. CDN URL Customization:** We currently do not support overriding the CDNURL when using multiple instances of Analytics.js.
42+
3343
## Do you see events appear in your debugger?
3444

3545
When you reload the page, does your debugger show a new [`page`](/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

Comments
 (0)