Closed kelly-howard-rh closed 2 months ago
@vladbailescu If you could take a look. Thank you!
@kelly-howard-rh , you're right, the code at https://github.com/adobe/aem-core-wcm-components/commit/27fda047ff40ca7f7be8889320b428bf5adc3e4c#diff-e289a30c0e7d5fd4e564b69136581640602ef9a99e21a9065f7522660a5488b3R31 does create a global (page/document) scope object named dataLayer
Thank you @vladbailescu ! Do you know what the timing is for this getting put into an AEM release?
Current plan is to include this in upcoming Core Components release (ETA: end of April) and include it in AEM 2024.5 release (ETA: end of May)
Thank you @vladbailescu for the quick attention to this issue!
Bug Report
Current Behavior Tracking events sent to GTM datalayer are not being recorded. Many errors appear in the browser console: core.wcm.components.commons.datalayer.acdl.lc-bf921af342fd2c40139671dbf0920a1f-lc.min.js:54 The following item cannot be handled by the data layer because it does not have a valid format: {"0":"set","1":"url_passthrough","2":false}
The error is coming from the Adobe datalayer script. These events are intended to be pushed to the GTM dataLayer variable. They are being intercepted by the Adobe datalayer.
Expected behavior/code Events should be pushed to the GTM datalayer and not invoke Adobe code.
Environment
AEM Version 2024.4.15977.20240418T174835Z Core components 2.24.6
Possible Solution We believe this is due to the new variable dataLayer being declared at the global level. It is overwriting the GTM dataLayer variable which existed before.
var dataLayer = window[dataLayerName] = window[dataLayerName] || [];
https://github.com/adobe/aem-core-wcm-components/pull/2724/commits/27fda047ff40ca7f7be8889320b428bf5adc3e4cCode that was calling
dataLayer.push()
was previously hitting the GTM dataLayer and is now being sent to the Adobe datalayer. Possible solution would be to change the name of this variable to something likeadobeDataLayer
.Additional context / Screenshots