Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Better support for dynamic link tracking #7477

Open
kevinoid opened this issue Mar 19, 2015 · 9 comments
Open

Better support for dynamic link tracking #7477

kevinoid opened this issue Mar 19, 2015 · 9 comments
Labels
Enhancement For new feature suggestions that enhance Matomo's capabilities or add a new report, new API etc.

Comments

@kevinoid
Copy link

Hello Piwik Developers,

I am using Piwik on a website with a frontend written in AngularJS and finding it very difficult to do link tracking with Piwik. The source of the difficulty is that enableLinkTracking only tracks links which exist and have an href property at the moment Piwik is initialized, which can be before or after Angular initialization, depending on script load timing. Although this can be combined or replaced with addListener on individual link elements, the lack of ability to query which elements are currently tracked and the dynamic nature of frameworks like Angular which often create and destroy elements can make this quite difficult and cumbersome.

I am curious if you have considered replacing the per-link event listener with a single event listener on the html element which can listen for click events as they bubble. This way all links, dynamic and static, could be tracked without additional work by the user. There would be a performance cost, since each click event would cause DOM traversal to check if the click was on an a or area element, but the cost seems reasonable for most uses. Alternatively, this could be avoided by creating a enableDynamicLinkTracking method to require users to opt-in to this behavior.

What do you think? If this approach seems reasonable, I'd be happy to send a PR. If not, perhaps alternative approaches for improved support of dynamic link tracking could be considered?

Thanks for your time and consideration,
Kevin

@mattab
Copy link
Member

mattab commented Mar 19, 2015

Hi @kevinoid

This sounds interesting, especially if you propose the working pull request 👍

Regarding speed: I guess listening to all clicks is costly, in case user clicks a lot like in some games, or when the DOM tree is huge and it's costly to know where we've clicked. we could put "safe nets" to skip some clicks if clickrate is high...

Maybe others will have some feedback as well!

@kevinoid
Copy link
Author

Hi @mattab

Thanks for the encouragement, I'll give it a shot.

Would you prefer the initial PR to apply the new behavior to the existing enableLinkTracking method (with or without the "safe nets" you mentioned), or should I create a new method such as enableDynamicLinkTracking? Obviously it can be changed later, just want to start as close as possible to the goal.

@mattab
Copy link
Member

mattab commented Mar 19, 2015

good to hear.

you can create enableDynamicLinkTracking and then we can easily call it from enableLinkTracking or not

@mattab mattab added the Enhancement For new feature suggestions that enhance Matomo's capabilities or add a new report, new API etc. label Apr 8, 2015
@mattab mattab added this to the Mid term milestone Apr 8, 2015
@mattab
Copy link
Member

mattab commented Apr 8, 2015

we'll be very happy to review your pull request if/when you create one 👍

@kevinoid
Copy link
Author

kevinoid commented Apr 8, 2015

Hey @mattab, thanks for the ping. Sorry about the delay, I had some unexpected priority changes on my current project which set me back a bit. I'm planning to have the first-draft PR ready in the next day or two, but if I don't, feel free to ping me again. It's still a priority for me!

@tomalex0
Copy link

Curios to know if this feature is available now? @mattab @kevinoid

@kevinoid
Copy link
Author

Good question @tomalex0. I left the project which needed this feature shortly after my last comment and I never got around to sending the PR. I'm not aware of any other work on the issue. I'll look around to see if I still have the prototype code I was working on and if it might still be useful.

@mattab
Copy link
Member

mattab commented Nov 21, 2016

@kevinoid as the issue is still opened we haven't implemented it yet. It would be great if you can create a pull request for this improvement 👍

@mattab mattab modified the milestones: Long term, Mid term Dec 5, 2016
@tomalex0
Copy link

tomalex0 commented Dec 13, 2016

@mattab , i'm using piwik in angular2 application, and i'm going to write a directive to address this issue for the mean time.

would like to know how you differentiate outlinks and download and how application urls are excluded from the outlinks and download

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Enhancement For new feature suggestions that enhance Matomo's capabilities or add a new report, new API etc.
Projects
None yet
Development

No branches or pull requests

3 participants