Piwik HTTP support request


#1

Hi everyone,
I am facing an issue when sending a http request to Piwik in Python.
When I execute the following script(used in order to send the height of a person through an Arduino):


import serial, requests, uuid
arduino = serial.Serial('/dev/ttyACM0', 9600)
while True:
	data = arduino.readline()
	print data
	r = requests.get('http://my-website.com/piwik/piwik.php?idsite=1&rec=1&action_name=Entree-magasin&uid='+str(uuid.uuid4())+'&e_c=entree-magasin&e_a=passage&e_n=taille&e_v='+str(data)+'')
	print r

I spent hours and hours trying to find why this request was not sent properly and I gave it a try with Google Analytics with the following script:


import serial, requests, uuid
arduino = serial.Serial('/dev/ttyACM0', 9600)
while True:
	data = arduino.readline()
	print data
	r = requests.get('http://www.google-analytics.com/collect?v=1&tid=UA-33333333-1&cid=6666666666&t=event&ec=Entree-magasin&ea=passage&el='+str(data)+'&ev='+str(data)+'')
	print r

and it works fine. For information data is a figure between 100 and 206.

Any ideas why is it working on Google Analytics and not Piwik?


(Matthieu Aubry) #2

Hi Nanor,

What is the actual URL that is generated by this code?

If you want to understand what’s the problem with the Tracking URL, the best way is to temporarily enable tracker debugging: Tracking HTTP API: API Reference - Matomo Analytics (formerly Piwik Analytics) - Developer Docs - v3

Then you will see in the response a possible error or missing parameter