Multiple Click Event listeners
Describe the bug
When you initiate the createInstance with the option as per documentation:
enableLinkTracking: false, // Important!
A new link tracking event listener is created. This lead thought the React Router Switch statement to generate 2 or more event listeners for outbound clicks. One for the instantiate and another one when the the component will load.
Added the linkTracking: false, // optional, default value: true still will create the same result. The issue is the following:
I see the issue be this line from the matomo-tracker (\src\MatomoTracker.ts):
` measure outbound links and downloads
// // might not work accurately on SPAs because new links (dom elements) are created dynamically without a server-side page reload.
this.enableLinkTracking(linkTracking)
[...] static enableLinkTracking(active: boolean) { window._paq.push(['enableLinkTracking', active]) }`
Searching on the Matomo documentation didn't find any instance of the use of the
window._paq.push(['enableLinkTracking', active])
More info: Disabling Download & Outlink tracking
To Reproduce Steps to reproduce the behavior:
- Use the createInstance as per documentation
- Load another component after the initial load
- Run the const { enableLinkTracking } = useMatomo()
- Monitor that the link inside the loaded component will trigger one call but the initial components for example (header/footer links) will trigger 2!
Expected behavior Depending on the parameters will have the option to disable the link tracking on the initial load
Desktop (please complete the following information):
Working with the latest version of the module: "@datapunt/matomo-tracker-react": "^0.1.5",
- OS: [Windows]
- Browser [ALL]
Additional context
Testing a React CRA project with everything updated
Adding the check to see if this is selected will resolve the issue:
if(linkTracking){ this.enableLinkTracking(linkTracking); }