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

Strip part of the URL from tracked outline or opt-out from outlink tracking for a specific link #16175

Closed
timdream opened this issue Jul 3, 2020 · 2 comments
Labels
answered For when a question was asked and we referred to forum or answered it.

Comments

@timdream
Copy link

timdream commented Jul 3, 2020

Hi!

My application has a link that goes to an URL like https://anotherwebsite.org/id?q=12345 which my app will replace the query parameter to a user input. As user input, the parameter is should not be collected. I intended to replace the tracked link as https://anotherwebsite.org/id?q=<number>.

There seems no easy way to achieve that. The documentation only mentions how to use CSS classes to classify the link as a outlink, and the JS method to call to count an outlink.

The first description does not fit my use case.

The second description, in my case, asks me to turn my link into

<a href="https://anotherwebsite.org/id?q=12345" target="_blank"
   onClick="_paq.push(['trackLink', 'https://anotherwebsite.org/id?q=%3Cnumber%3E', 'link']);">Link</a>

Will likely to cause the link to be tracked twice, although I didn't try to verify if that's really the case (see note below).

I figured I could avoid that by opt-out from link tracking on the link and call the JS method myself, like

<a href="https://anotherwebsite.org/id?q=12345" target="_blank"
   class="matomo-dont-track"
   onClick="_paq.push(['trackLink', 'https://anotherwebsite.org/id?q=%3Cnumber%3E', 'link']);">Link</a>

but such option does not exist (unless not explained on the doc).

How do I achieve the desired effect with Matomo? Please let me know if this is actually possible; if so I we should classify this issue to a documentation one.

Thanks!

Note: I am not sure how to test this out without polluting my production dataset. Mamoto can avoid duplicate tracking by making sure trackLink is only register once per click MouseEvent event loop, but that's unlikely.

@tsteur
Copy link
Member

tsteur commented Jul 5, 2020

@timdream you can give your link a class ignore and then track the click manually using onclick. This way Matomo will ignore it and you won't track it twice. If you prefer to use another class name you can configure alternatively different class name like _paq.push(['setIgnoreClasses', ['matomoignore']]);

@tsteur tsteur closed this as completed Jul 5, 2020
@tsteur tsteur added the answered For when a question was asked and we referred to forum or answered it. label Jul 5, 2020
@timdream
Copy link
Author

timdream commented Jul 6, 2020

Got it. Thank you very much. I should have read the documentation section to the end.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
answered For when a question was asked and we referred to forum or answered it.
Projects
None yet
Development

No branches or pull requests

2 participants