For the evaluation of an intranet search I need to track user clicks on search results. Since I do not want to modify the URL and track the event on the target page, I’m trying to track the click in javascript and call piwikTracker.trackGoal(…). However, in some browsers I have to wait a short time after calling trackGoal before following the actual link, otherwise the goal is not tracked. Is it possible to get a callback, when the goal is tracked, so I do not have to wait a fixed amount of time (without being sure that all goals are tracked).
This was asked a while ago, yet I feel this is very relevant not just to me but to anyone who adds click events to buttons that are links or form buttons (a task that’s very common). I believe that without an appropriate callback function there’s a lot of lost data.
So I’d like to re-ask this question:
Is there a callback function in Piwik for events? (Assuming there isn’t, can we add that to the next release please!)
If not, could someone give me an idea how I could write it either for my front-end or as a plugin for Piwik? As I understand Piwik tracks using a pixel so this should be as simple (or as complex) as firing an event once that pixel is loaded by the browser.
OK this wasn’t “tonight” at all, not even close. Sorry about that.
But I’ve used the code from that branch and it seems to work. I’ve tested the front-end (JavaScript) and the fact that the events are actually being recorded in database (via Piwik dashboard). Works with Piwik 2.16.1