cURL to test API calls

How to use cURL with piwikpro for development, creating “direct entry” action-based metrics using Tracking HTTP API.

1 You don’t need to post. Get will work.

  1. Your tracking call will return something like:

GIF89a?!?,D;

That is because you can call piwik as though it was an image load in javascript, and that will track your page. So it returns an image.

Passing the parameter: &set_image=0 will suppress this and return a 204.

Here’s an example:

curl “https://example.piwikpro.com/piwik.php?idsite=3&rec=1&action_name=ViewForm&send_image=0&url=http://A_FAKE_WEBSITE/FAKEPAGE_ACTUALLY_AN_ID/&_id=ABCDE0123401234A&apiv=1

The FAKE_WEBSITE should be set up as a website in the settings panel. This will let you get completely separate metrics for each fake website. A_FAKE_WEBSITE doesn’t need to be valid url, it can be: GARDENA_STORE_82 or an individual customer or client if you are hosting or providing SAAS.

&_id= is a user id and it has be 16 hex digits. This gets used to create uniques etc.

Everything on the Tracking HTTP API can be curled. The more complex example given there shows how to pass a custom embedded JSON object - that’s what the _CVAR element is.

Details here: Tracking HTTP API: API Reference - Matomo Analytics (formerly Piwik Analytics) - Developer Docs - v3