Open christophercr opened 11 months ago
Hi @christophercr Thank you for your message and the suggestion!
Actually this library was not originally designed to work specifically with Tag Manager, but I think it would be a great idea to provide better integration indeed!
Your suggestion seems good. I would just suggest to use dependency injection instead of instantiate a class directly.
Feel free to open a PR so we can work on it!
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 ofngx-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
andStandardMatomoTracker
. 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
orStandard
ones.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 thepush()
for example or in anytrackXXXX()
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?