-
Notifications
You must be signed in to change notification settings - Fork 9
Gracefully fail on window.dataLayer name conflict #15
base: master
Are you sure you want to change the base?
Conversation
lib/index.js
Outdated
@@ -30,6 +30,12 @@ var GTM = module.exports = integration('Google Tag Manager') | |||
*/ | |||
|
|||
GTM.prototype.initialize = function() { | |||
// If window.dataLayer already exists and isn't an array, fail gracefully. | |||
if (window.dataLayer && !Array.isArray(window.dataLater)) { | |||
console.error('window.dataLayer already exists - not running Segment<>GTM destination') |
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 wonder if GTM allows us to use something other than |
I believe that we should simply allow the data layer's name to be passed in as a flag here for the &l args instead and default to dataLayer. Adding to the ticket so we can evaluate the best way to support this. analytics.js-integration-google-tag-manager/lib/index.js Lines 21 to 22 in f661ed6
|
We SHOULD still keep this no-op if the chosen data layer name is taken. |
Hi @Peripheral1994, as part of the monorepo migration, this issue has been moved to new issue. Our engineers have been notified and will prioritize and work on it ASAP. Thank you! For more information, see README.md. |
I'm updating the body of this PR to do some testing, don't mind me - Carlos