Bulk tracking HTTP syntax problem

Hello,
I am hard time getting bulk tracking over HTTP, posting to piwik.php, to work. I just take 3 of my regular requests (that work fine by themselves) and create a string using the syntax described at Tracking HTTP API: API Reference - Matomo Analytics (formerly Piwik Analytics) - Developer Docs - v3, and them POST it to piwik.php:

http://MYURL/piwik.php{“requests”:["?idsite=6&rec=1&_id=0000000051B49013&url=http://MYURL/App%20Open&ua=Mozilla/5.0%20(Macintosh;%20Intel%20Mac%20OS%20X%2010_10_1)","?idsite=6&rec=1&_id=0000000051B49013&url=MYURL/open&e_c=Operating%20System&e_a=Mac&e_n=10.10.1&e_v=1","?idsite=6&rec=1&_id=0000000051B49013&url=MYURL/open&e_c=OEM%20Software&e_a=Aion&e_n=Mac&e_v=1"],}

I substituted the real url for MYURL in the above example.

This is how I understand it should be constructed. When I try it in a browser (normally I send it from desktop app), it takes me to All Websites Dashboard, with no effect on the stats. I get no errors from debug.

I also tried it with “?” after piwik.php - same result.

I’m sure it’s something silly. Any ideas?

Thank you.

You need to send a POST request, and the JSON data needs to be the body of the request. In your example you put it in the URL, which doesn’t work.

Here is an example using curl (taken from the documentation):


curl -i -X POST -d '{"requests":["?idsite=1&url=http://example.org&action_name=Test bulk log Pageview&rec=1","?idsite=1&url=http://example.net/test.htm&action_name=Another bulk page view&rec=1"]}' http://piwik.example.com/piwik.php

So in your exampel you need to send this data as the POST body (either with curl or with whatever other tool):


{"requests":["?idsite=6&rec=1&_id=0000000051B49013&url=http://MYURL/App%20Open&ua=Mozilla/5.0%20(Macintosh;%20Intel%20Mac%20OS%20X%2010_10_1)","?idsite=6&rec=1&_id=0000000051B49013&url=MYURL/open&e_c=Operating%20System&e_a=Mac&e_n=10.10.1&e_v=1","?idsite=6&rec=1&_id=0000000051B49013&url=MYURL/open&e_c=OEM%20Software&e_a=Aion&e_n=Mac&e_v=1"],}

OK, that makes sense, I missed that part.

I am doing it from Xojo. I set everything that is in the curly brackets as a payload of my POST request, sent it to http://MYURL/piwik.php, and after I also removed the extra comma from the end of my string before the right curly bracket, it worked!!

Thanks a million!!