Set Piwik variables from Node.js and Express


Our application is expected to have very high volumes of transactions. In order to reduce the amount of http calls to our Piwik server, the architecture passes Piwik page view and event data to a Node.js frontend to Amazon Simple Queue Service. A process batches up the transactions from the queue to make a single call to Piwik with a set of data.

Amazon’s SQS does not guarantee the order of reading responses from the queue so we had to specify the Piwik ‘cdt’ parameter in the call to make sure that the correct time was associated with each item.

After a lot of attempts, we finally figured out that the ‘cdt’ parameter is a simple UNIX timestamp!

Psuedo code:

//calculating UTC datetime it looks like server need unix timestamp:P
process.env.TZ = ‘America/New_York’; = parseInt(;

(Matthieu Aubry) #2

Hi there, It does work with timestamp, but it also works with datetime:

cdt — Override for the datetime of the request (normally the current time is used). This can be used to record visits and page views in the past. The expected format is: 2011-04-05 00:11:42 (remember to URL encode the value!).

reference; Tracking HTTP API: API Reference - Matomo Analytics (formerly Piwik Analytics) - Developer Docs - v3