Directly tracking API calls

Hi All

I’m very new to PIWIK - so please pardon my ignorance.

I’ve got an AngularJS app (‘backed’ by Django) that is configured to use PIWIK. Its working fine.

I’d like more low level control of PIWIK - specifically

  • the ability to track how many times a specific button is clicked on a page
    • this could be configured in html
  • the ability to call the PIWIK tracking API from my ‘backend’ code (aka Python). This way I could track how often calls are made to my API server

Any help would be greatly appreciated.


Your first option is probably being tracked anyway but you can control the exact tracking you need. Documentation is at Tracking API and Tracking Guide.

I would look at the trackEvent call.

On my site I use Sencha’s EXT-JS. In my router code I have:

_paq.push(['setUserId', userid]);
_paq.push(['setDocumentTitle', currentTitle]);

The first line sets the current userid (Which I get from the cookie the user logs in with). The second line sets the document title to the correct “Page”. The third line actually calls the tracking code.

In your case you probably want something like:

_paq.push(['trackEvent', 'Button', 'Clicked', 'ButtonName', 'ButtonValue'])

For the back end you would need to look at the HTTP Tracking API.