For support questions, please consider using Gitter - Chat
I'm submitting a ...
[ ] bug report
[x] feature request
[ ] question about the decisions made in the repository
If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem
When tracking events in ngOnInit, (at least with GTM), these events are pushed to the data layer ahead of the pageTrack event.
This seems to be due, to ngOnInit being invoked on the component before the NavigationEnd event is fired.
This is especially noticeable when getting data from internal services, that rely on subscriptions on behaviorsubjects, where data may already be ready, and will be delivered immediatly.
i.e.
this.myService.subscribe( x => {
// record that
this.angulartics2.eventTrack.next({ action: 'productImpression', properties: { product: x.partnumber }});
});
What is the expected behavior?
Analytics events triggered by a component, comes after the page tracking for the page.
I was considering, that maybe this could be solved, if angulartics itself buffered all eventTracks, that happen while a navigation is in progress.
I.e. not only react to NavigationEnd by putting out a pageTrack event, but also using the NavigationStart event to put the eventTrack queue into a "buffer mode", where any events registered would be postponed temporarily until the pageTrack occurs.
What is the motivation / use case for changing the behavior?
It can be somewhat complicated to correctly track based on data as ngOnInit is the desired place to set up subscriptions, but the "context" of those events are not set until NavigationEnd occurs.
For support questions, please consider using Gitter - Chat
I'm submitting a ...
[ ] bug report
[x] feature request
[ ] question about the decisions made in the repository
If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem
When tracking events in ngOnInit, (at least with GTM), these events are pushed to the data layer ahead of the pageTrack event.
This seems to be due, to ngOnInit being invoked on the component before the NavigationEnd event is fired.
This is especially noticeable when getting data from internal services, that rely on subscriptions on behaviorsubjects, where data may already be ready, and will be delivered immediatly.
i.e.
Analytics events triggered by a component, comes after the page tracking for the page.
I was considering, that maybe this could be solved, if angulartics itself buffered all eventTracks, that happen while a navigation is in progress. I.e. not only react to NavigationEnd by putting out a pageTrack event, but also using the NavigationStart event to put the eventTrack queue into a "buffer mode", where any events registered would be postponed temporarily until the pageTrack occurs.
Environment: