-
Notifications
You must be signed in to change notification settings - Fork 372
Support for Multiple Versions of Analytics.js #7005
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
src/connections/sources/catalog/libraries/website/javascript/troubleshooting.md
Outdated
Show resolved
Hide resolved
src/connections/sources/catalog/libraries/website/javascript/troubleshooting.md
Outdated
Show resolved
Hide resolved
src/connections/sources/catalog/libraries/website/javascript/troubleshooting.md
Outdated
Show resolved
Hide resolved
src/connections/sources/catalog/libraries/website/javascript/troubleshooting.md
Outdated
Show resolved
Hide resolved
src/connections/sources/catalog/libraries/website/javascript/troubleshooting.md
Outdated
Show resolved
Hide resolved
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. | ||
### Analytics.js Snippet Loaded More Than Once | ||
|
||
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: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I haven't tested, but it "should" be possible to use two snippets in the same page --just change one snippet to use the another variable name (eg analytics1 and analytics2).
The new snippet makes it super easy to rename the analytics variable to something else.
Worth testing, there were a lot of assumptions built into the library that there would only be one snippet, but we've gradually refactored them out.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Discussing this on Slack: https://twilio.slack.com/archives/C9Z93GW76/p1725549203131189?thread_ts=1725380202.861859&cid=C9Z93GW76
hi @prigiattiperrut and @silesky - any movement on this PR? Should we close this PR? |
Thank you for your contribution! Your pull request is merged, but may take a day or two to appear on the site. |
Proposed changes
Updated documentation to reflect the possibility of running multiple versions of Analytics.js (e.g., a snippet version and an npm version) with different write keys in the same environment.
Merge timing
ASAP once approved
Related issues (optional)
segmentio/analytics-next#1127
https://twilio.slack.com/archives/C9Z93GW76/p1725380202861859