-
Notifications
You must be signed in to change notification settings - Fork 19
Description
First of all thanks a lot for such a useful lib! Works like a charm! 👏
I would like to use the Matomo Tag Manager and I also need to "push" other data into the _mtm variable. Perfhaps this is out of the scope of ngx-matomo and maybe what I'm going to explain below is not feasible, but who knows 😛
Currently there is no way to perform custom logic nor pushing custom data into the _mtm variable because there are only 2 trackers to use in the library: NoopMatomoTracker and StandardMatomoTracker. The latter as its name suggests, works out of the box with a standard Motomo traking workflow and uses the _paq variable.
I think this could be enhanced by being able to provide a custom Matomo tracker class, via the config for example, so that such class can be instantiated instead of the Noop or Standard ones.
export function createMatomoTracker(
config: InternalMatomoConfiguration,
platformId: Object,
ngZone: NgZone,
): MatomoTracker {
if (config.disabled || !isPlatformBrowser(platformId)) {
return new NoopMatomoTracker();
}
return config.customTrackerClass;
? new config.customTrackerClass(ngZone, config)
: new StandardMatomoTracker(ngZone, config);
}From then on, everything should be fairly simple for the developer since the tracker class should extend the MatomoTracker abstract class as the other 2 trackers. This way any custom logic could be placed in the push() for example or in any trackXXXX() method if needed.
Not really sure if this would fit in ngx-matomo in its current state cause what I actually need is to customize data to be sent to the Tag Manager and trigger some other logic in my own app whenever such events are sent.
What do yo think?
