trackLink function logging internal links as outgoing

For a project of mine it is required to track hits to a certain URL as well as clicks on some javascript-enabled button to show the same content, but without actually loading the URL.

I tried to do this with Piwik, and figured out that it might be a good idea to use the trackLink function. So I added some tag like


onClick="javascript:_paq.push(['trackLink', 'http://mydomain.org/path/to/content', 'link']);"

as I found in the Piwik documentation. This works in a way now, but the hits are all treated as “Outgoing links” in Piwik, so they don’t show up in the “Pages” overview, but in the “Outgoing links” tab.

I understand this might be by design because in the documentation it sounded like “use this function for logging external links and downloads”, but I don’t see the reason for this. Wouldn’t it be better to filter links by domain, as it is done with “normal” page clicks, so that links to “mydomain.org” will always show on the “Pages” tab? The current situation doesn’t seem to make too much sense to me because I can’t imagine why somebody would want to see internal links on the “Outgoing links” page.

Is there a better method to do what I’m trying to achieve? Any suggestions would be very much appreciated.

Maybe track it as an event?

http://piwik.org/docs/event-tracking/

Thanks for the suggestion. Of course it would be an option to use event logging, but it wouldn’t improve the situation. The logged events would show on a different Piwik page than the actually visited pages as well, no?
What my customer wants me to do is to “emulate” a real page view of a certain URL when a link is clicked, but the page is not visited.

if you want or need to track an actual pageview then use trackPageView() - it will show up in Pages report.

otherwise use Event Tracking as @lesjokolat suggested

I’ve already tried to use trackPageView, but I didn’t get the desired results as well.

I found something about this in the documentation and used the following code on click:


_paq.push(['setCustomUrl', 'http://mydomain.org/path/to/content']);_paq.push(['trackPageView']);

I thought this should log a page view with the URL you set with “setCustomUrl”. But it didn’t work. It seemed to log the page view, but not the URL of the link because you could see the page view on the “Page titles” tab, but not on the “Pages” tab.