I’m using the TagManagementFeatureModule in version 3.2.2. I was wondering if there is a recommended/documented OOTB way to use Spartacus events (CartAddEntrySuccessEvent, CartRemoveEntrySuccessEvent, CartUpdateEntrySuccessEvent) for GTM.
I don’t think I see that the dataLayer pushed entry contains the event key, which is used by GTM triggers. Same case for the NavigationEvent, is there an OOTB way to use it to capture Page Views?
Edit: Currently I created my own module and extending the GtmCollectorService, where I implement the map
function to add this event key based on event.constructor.name
, but I was assuming there was a default way to do it with the GtmModule.
Yes, you're right, there is no OOTB way to do this. The reason is simple - it all depends on the TMS solution being used, and on the specific clients needs.
That being said, your approach to override the GtmCollectorService
and implement map
is correct. However, instead of event.constructor.name
I suggest to use the static type
property that's present on each of the event classes.