forcedDateTime not working


#1

Hi there

Thanks for Piwik - it’s a great piece of software.

I’ve hit one snag, though. I’m using the PHP PiwikTracker object to post a historic visit to our Piwik tracker site. Everything is registering correctly: keywords, custom variables, forced urls etc.

But my forcedDateTime is failing to be acknowledged by Piwik. Visits that include, eg

&cdt=1296546002

are being registered with their actual arrival time, not the historic date.

I’m using the SuperUser token. I’ve edited the piwik_site.ts_created field to backdate the website creation to before the cdt time. I’ve dropped all old archives. I’ve tried using a string for the cdt instead of a timestamp.

But still cdt seems to be being ignored. Any advice gratefully received.

X


(Matthieu Aubry) #2

Can you please copy here the full http request you make to Piwik?

it should work but only if passing correct token_auth parameter (admin or super user)

thanks


#3

Hi Matt

Many thanks for getting back on this. I’ve removed the actual token, but the one I’m sending is for the user who was created on installation of Piwik. I believe this is the superuser. I’ve also aliased the target so the link below doesn’t point to our actual website but the structure is the same. Let me know if that’s a problem.

The cdt in this request is a Unix timestamp. I’ve tried using

setForceVisitDateTime(date(“Y-m-d H:i:s”, $timestamp))

with no luck so far.

What’s happening currently is that Piwik is putting all the data where I need it, but reporting this event as coming in with today’s date and time, rather than as having come in on 2011-02-01 07:40:02.

Also, the IP is being reported as the actual IP rather than the forced one 10.4.0.1.

http://ma.j-plugs.com//piwik.php?idsite=8&rec=1&apiv=1&rand=89338258&cip=10.4.0. 1&cid=fff002B0114ac758&cdt=1296546002&token_auth=<>&_cvar=%7B%221%22%3A%5B%22customer%22%2C%22apple%22%5D%2C%222%22%3A%5B%22store%22%2C%22apple_SW111TN%22%5D%2C%223%22%3A%5B%22terminalid%22%2C%22fb751e603559a53d153d599bb273df2e%22%5D%2C%224%22%3A%5B%22sensorId%22%2C%22002B0114%22%5D%2C%225%22%3A%5B%22productName%22%2C%22htDesireHd%22%5D%7D&url=http%3A%2F%2Fapple.multplxyz.com%2Fapple%2FSW111TN%2FSEN-PICK%2FhtDesireHd%2F002B0114%2F2011-02-01T08%3A40%3A02%3Fpk_campaign%3DHTC&urlref=&action_name=SEN-PICK+%7C+htDesireHd+%7C+fonehouse+%7C+SW111TN+%7C+id%3D706392”

Hope that makes some kind of sense. (And thanks again for Piwik. Haven’t been using it long but it’s already saved me more time than I’ve put into it.)

David


(Matthieu Aubry) #4

If IP is not overloaded neither, the problem is probably with authentication and token_auth

  1. Make sure you are using latest version
  2. Enable debug as explained in: Tracking API - Analytics Platform - Matomo
    then visit you piwik.php request directly and read the output

#5

Hi there

The problem seems to be as follows:

cdt=1296546002

is being ignored. So I switch to using a date string in my php as follows:

$t->setForceVisitDateTime(date(“Y-m-d H:i:s”, 1296546002))

This is being rendered as:

cdt=2011-02-01+07%3A40%3A02

rather than

cdt=2011-02-01%2007%3A40%3A02

I believe the setForceVisitDateTime() function is adding the +.

PiwikTracker.php then uses

strtotime($this->forcedDatetime)

which yields “”.

Substituting %20 for + I get the historic entry I need in my piwik site.

Am I correct, or is something in my code adding the unwanted +?

Thanks in advance


(JulienM) #6

Sorry for the delay, setForceVisitDateTime seems to be broken when fed with a unix timestamp.

I have reported it here : Tracker API setForceVisitDateTime should accept UNIX Timestamp as well as date time · Issue #2299 · matomo-org/matomo · GitHub