I have a question to manual goal tracking using the image API.
One can use piwikTracker.trackGoal() (if synchronous tracker used) for manual goal tracking with the JS tracker, or, alternatively TWO image tracker calls to achieve the same goal. (Two because otherwise only the goal will be logged on a call with “idgoal”, not the also provided “action_name”. So that one needs to separate “idgoal” and “action_name” in two different image tracker calls for both to be logged. That is also the way the JS tracker does it – it also makes two calls if piwikTracker.trackGoal() is set.)
I use the following tracker for manual goal tracking:
Specifically, I use that to track error pages (e.g. 404), to track broken links, etc. And use negative goal value for that. It’s a hobby website, but I guess that commercial websites would have the same problem.
Reason seems to be: Both calls are issued before the visitor gets a cookie set, so that Piwik doesn’t detect both calls as coming from the same visitor.
Subsequent calls will then be detected as coming from the “second” visitor. With only the first call (the achieved “goal”) appearing with the “first” visitor.
That problem does not occur with the JS tracker, seemingly because it uses following additional parameters on the call: “id”, “_idts” and “_viewts”. With them set to the same values on both calls and therefore the calls detected as coming from the same visitor. Their values also appear in the “_pk_id…” cookie.
How can I bring Piwik to detect both above calls as coming from the same user?
My guess would be using (maybe some of) the above “id”, “_idts” and “_viewts” parameters. (E.g. setting their values to something like hashes of IP address+User Agent string+various other request headers (all being available in PHP.) BUT: I do not want to implement visitor tracking in my application by completely side-stepping Piwik cookie-based visitor management. I only want the two above first calls to be detected as coming from the same user, until the Piwik cookie-based management kicks in. How could that be done in an officially supported way?
What’s the reason for the need to separate ”idgoal” and “action_name” in two calls? Why can’t Piwik log both when both are provided on the same call?
A side effect of using two calls is also that their log order varies – sometimes the goal appears before the “action” in the log, and sometimes after it. (At least with my lame shared host, with largely varied server response times to the above separate calls.)
Thanks in advance!