Arnaud73 / ngx-matomo

Matomo (aka. Piwik) web analytics for Angular applications
MIT License
102 stars 47 forks source link

feat(injector): Add optional skipTrackingInitialPageView init parameter #31

Closed matt-senseye closed 1 year ago

matt-senseye commented 4 years ago

Summary

This PR adds an additional (optional) parameter to the init() function of the injector service which allows the user to initialise Matomo without automatically tracking the initial page load. Behaviour is unchanged by default, but if the user chooses to pass true to the new parameter it becomes possible to avoid tracking the initial page load - giving the user more control over when and how the first page event gets tracked.

Detailed description of use case

In our application, we needed to:

By subscribing to the Angular router's events observable, the pipeline above worked nicely, but we found that ngx-matomo was also automatically capturing the initial page load as part of the process of initialising ngx-matomo. As a result, the events in the Matomo visitor log were inconsistent and the first log for each visit excluded the custom dimensions because they originated from the automatic call to trackPageView inside ngx-matomo.

I think giving the user the ability to disable this functionality would be useful in situations where more control is needed over the page tracking, so am hoping that this contribution would enhance the library.

daganM commented 4 years ago

Completely agree with this feature. When I'm using Matomo in my Ionic app, as I track each page on loading, the first page is tracked twice (so always one more page view than there really is).

Seems a good idea to me!

alexhebing commented 4 years ago

Having the same problem here, and would love this feature!

matt-senseye commented 4 years ago

@Arnaud73 what are your thoughts on this? It would be great to get this merged into the main project if possible, as I'm having some trouble installing my forked version of the library from my app and it seems others would benefit from this change too.

daganM commented 4 years ago

@Arnaud73 , wouldn't it be possible to merge this?

daganM commented 4 years ago

Sorry to insist, but it looks like more and more everyday that the project is no more alive. Is it still ? If yes, this pull request SHOULD be merged in my opinion.

Best,

Arnaud73 commented 1 year ago

I did not merge this enhancement as-is, however I implemented this exact suggestion on the new code base (ngx-matomo 1.0 and newer). This option can be found in the config object given to MatomoModule.forRoot(config) (false by default). Thanks for the suggestion!