Events API - Query Single Action

I setup a custom trackEvent using this code:


<a href="#" onclick="javascript:_paq.push(['trackEvent', 'Like', '<?php echo $id ?>']);">Like Me</a>

So “Like” is the category, and “$id” is the action, which will be different depending on which page is being viewed.

This works fine and successfully get the custom event into my Piwik dashboard under the “Like” category. For example, I clicked on this link on 3 different pages so I have 10, 11, and 12 as actions in my dashboard.

To query them, I’m using this URL in a HTTP request:

http://www.MYPIWIKURL.com/?module=API&method=Events.getAction&idSite=1&period=day&date=today&format=JSON&token_auth=MYAUTHTOKEN

This returns an array with all 3 of the actions listed as nested arrays. I’m wondering, however, how I can return only the array with the action I want to view? For example, action 10?

I tried adding “e_a=10”, “action_name=10”, and “segment=actions==10” to the URL, but they aren’t recognized.

Could someone point me in the right direction for querying a single action within a category? Seems like I’m almost there!

Also–I do know that I could loop through the array and get the action I want, but eventually there will be thousands of actions, so that wouldn’t be very efficient I don’t think.

Thanks for any help!

What you want is restrict a Piwik API response report to show only one row matching your search. It’s the parameter &label= that should help you. See doc at: Reporting API Reference: API Reference - Matomo Analytics (formerly Piwik Analytics) - Developer Docs - v3

1 Like

Thanks!! And thanks for developing great software. Will definitely be donating.