EmmanuelRoux / ngx-matomo-client

Matomo analytics client for Angular applications
https://matomo.org/
MIT License
74 stars 16 forks source link

How to disable link tracking? #44

Closed Giovanni-NL closed 2 years ago

Giovanni-NL commented 2 years ago

Is there any way to completely disable link tracking? I have tried to use the enableLinkTracking(false) method on the tracker, but that does not stop links from being tracked, it only seems to stop middle- and right-button mouseclicks on URLs from being tracked.

I am only interested in event logging of clicks and navigation actions within my application (which work perfectly fine with ngx-matomo).

How can I completely disable the logging of clicks on URLs that result in requests like this? my.domain.com/application/matomo.php?link=https://my.target.url/

EmmanuelRoux commented 2 years ago

Hi @Giovanni-NL

Set enableLinkTracking: false in your configuration to disable link tracking.

You should not call tracker.enableLinkTracking() at all, even with false as parameter. Calling this method will always enable link tracking (the boolean parameter only controls tracking behavior).

If still not working as expected, can you please provide your code?

Giovanni-NL commented 2 years ago

I have simplified the actual URLs, but this is what I have in my app.component.ts

NgxMatomoTrackerModule.forRoot({
  trackerUrl: "https://my.domain.com/matomo.php",
  siteId: 1,
  scriptUrl: "https://my.domain.com/js/piwik.js",
  enableLinkTracking: false
}),

I have tried with and without actually calling tracker.enableLinkTracking(). The current code does not make that call anywhere, but links are still being tracked...

-- Addendum: Even when I completely remove enableLinkTracking from the configuration, links are being tracked.

EmmanuelRoux commented 2 years ago

[...] The current code does not make that call anywhere, but links are still being tracked...

What do you mean? Can you see http requests to matomo.php?

Are you sure the tracking code provided by Matomo is not included in your app? Also, can you please provide a minimal repro ? (eg. on Stackblitz or other online tool)

Giovanni-NL commented 2 years ago

Yes, I can see the requests going out to matomo.php on the Network tab of the Chrome Developer tools.

Uploading the current application is something I cannot do, but I will try to create a small demo application that shows the same behavior and put that somewhere on github.

Giovanni-NL commented 2 years ago

The demo application I've made works like a charm... It defaults to link tracking on, and with enableLinkTracking: false in the configuration it stops the tracking of links. No matter what I try, I cannot reproduce the issue in this application.

My conclusion is that ngx-matomo works as intended, and the error lies somewhere in our original application. I'm just having a hard time troubleshooting where exactly things go wrong.

For now this issue can be closed. Thanks for your input.

EmmanuelRoux commented 2 years ago

Hi @Giovanni-NL, thanks for the feedback.

It defaults to link tracking on, and with enableLinkTracking: false in the configuration it stops the tracking of links.

That's indeed the expected behavior of the lib


You can still post an (anonymized) extract of your application's code, maybe that can help... Also double-check there is no tracking code manually embedded in your app.