API: Time on page / time_spent_ref_action has 0 values

Hello,

there seems to be some clarification needed or this is bug. Using the bulk feature of Piwik while using the Piwik C# Tracking API I’m getting 0 values for the “Time on page”

Statistics are inserted fine, with the exception of the “Time on page” / time_spent_ref_action. It has for almost all records a value of 0. Sometimes it has the correct value.

These are some of the Urls I’m sending via ASP.NET Application to a IIS Server on the Network:


piwik.php?idsite=1&rec=1&apiv=1&r=415671&cip=::1&cid=8d140f01680e0000&cdt=2015-10-09 09:13:30&_idts=1436440636&_idvc=35&url=myurl1&country=en
piwik.php?idsite=1&rec=1&apiv=1&r=415671&cip=::1&cid=8d140f01680e0000&cdt=2015-10-09 08:53:48&_idts=1436440636&_idvc=35&url=myurl1&country=en
piwik.php?idsite=1&rec=1&apiv=1&r=415671&cip=::1&cid=8d140f01680e0000&cdt=2015-10-09 08:53:52&_idts=1436440636&_idvc=35&url=myurl9&country=en
piwik.php?idsite=1&rec=1&apiv=1&r=415671&cip=::1&cid=8d140f01680e0000&cdt=2015-10-09 07:53:52&_idts=1436440636&_idvc=35&url=myurl9&country=en
piwik.php?idsite=1&rec=1&apiv=1&r=415671&cip=::1&cid=8d140f01680e0000&cdt=2015-10-09 07:51:05&_idts=1436440636&_idvc=35&url=myurl7&country=en
piwik.php?idsite=1&rec=1&apiv=1&r=415671&cip=::1&cid=8d140f01680e0000&cdt=2015-10-09 07:49:27&_idts=1436440636&_idvc=35&url=myurl1&country=en
piwik.php?idsite=1&rec=1&apiv=1&r=415671&cip=::1&cid=8d140f01680e0000&cdt=2015-10-09 07:49:56&_idts=1436440636&_idvc=35&url=myurl3&country=en
piwik.php?idsite=1&rec=1&apiv=1&r=415671&cip=::1&cid=8d140f01680e0000&cdt=2015-10-09 07:49:04&_idts=1436440636&_idvc=35&url=myurl6&country=en
piwik.php?idsite=1&rec=1&apiv=1&r=415671&cip=::1&cid=8d140f01680e0000&cdt=2015-10-09 07:49:09&_idts=1436440636&_idvc=35&url=myurl6&country=en
piwik.php?idsite=1&rec=1&apiv=1&r=415671&cip=::1&cid=8d140f01680e0000&cdt=2015-10-09 07:48:03&_idts=1436440636&_idvc=35&url=myurl3&country=en
piwik.php?idsite=1&rec=1&apiv=1&r=415671&cip=::1&cid=8d140f01680e0000&cdt=2015-10-09 07:48:13&_idts=1436440636&_idvc=35&url=myurl4&country=en
piwik.php?idsite=1&rec=1&apiv=1&r=415671&cip=::1&cid=8d140f01680e0000&cdt=2015-10-09 07:48:29&_idts=1436440636&_idvc=35&url=myurl4&country=en
piwik.php?idsite=1&rec=1&apiv=1&r=415671&cip=::1&cid=8d140f01680e0000&cdt=2015-10-09 07:47:56&_idts=1436440636&_idvc=35&url=myurl5&country=en


Afterwards, I’m invalidating the related date and reload all data.

What exactly am I doing wrong here?

best wishes,
Marius

Hello
can you try URL encode the parameters, including cdt ?

Hi,

the C# Wrapper is doing that already.
For cdt I added that, but without any changes in the result.

best wishes,
Marius

I did some tests and probably found a reason. Piwik does not count the real difference in cdt time, it is tracking the time the request was made.

I made two requests. For the first one I set a time of 09:01:00, for the second 09:01:30. Between both requests I waited ~10 seconds
These are the debug outputs of the requests:


First:
array (
...
  'cdt' => '2015-10-09 09:01:00',
...
)


Second:
array (
...
  'cdt' => '2015-10-09 09:01:30',
...
)


Inserted new action:
array (
...
  'time_spent_ref_action' => 10,
...
)

Is this wrong behaviour easy to fix?

With an reverse order of the bulk requests (oldest -> newest) the time_spent_ref_action is filled correctly. I was thinking time_spent_ref_action was processed after the bulk has been submitted.
Probably a good idea to make a short notice about the correct date order in bulk requests.

hi Phalynx

Please create an issue to request improvements to documentation, we will gladly do it: Issues · matomo-org/piwik · GitHub

Hello Matt,

did that.

Thanks for your support.

best wishes,
Marius