Skip to content
This repository has been archived by the owner on Jan 30, 2023. It is now read-only.

Multiple Click Event listeners #179

Open
harrygi opened this issue Jun 22, 2020 · 0 comments
Open

Multiple Click Event listeners #179

harrygi opened this issue Jun 22, 2020 · 0 comments
Labels
bug Something isn't working need more info

Comments

@harrygi
Copy link

harrygi commented Jun 22, 2020

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:

  1. Use the createInstance as per documentation
  2. Load another component after the initial load
  3. Run the const { enableLinkTracking } = useMatomo()
  4. 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); }

@jonkoops jonkoops self-assigned this Sep 1, 2020
@jonkoops jonkoops added need more info bug Something isn't working labels Sep 1, 2020
@jonkoops jonkoops removed their assignment Feb 7, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working need more info
Projects
None yet
Development

No branches or pull requests

2 participants