When I add a custom datalayer as described here it will fire a message that can be seen in the G-Tagmanager with the added datalayer, but it will also show in every rout-/ history change event after that.
Here is what I have so far:
const tryToSendGADataLayer = () => {
const tagManagerArgs = {
dataLayer: {
ecommerce: {
purchase: {
actionField: {..},
products: [{..}]
}
}
},
dataLayerName: 'ecommerce'
}
TagManager.dataLayer(tagManagerArgs)
}
I only want the datalayer to be added in the Message event and not in all the events after that.
window.google_tag_manager[ GOOGLE_TAG_MANAGER_ID].dataLayer.reset()