How to retrieve views & downloads by custom variable?

Hello! I am extremely new to Matomo and I’m having trouble understanding a lot the terminology used in the API documentation. I’m using Matomo to track a Drupal site that is configured to work as a digital archive, and one “page” can have many different URL aliases route to it so I am using an object ID as a custom variable so that no matter what route a user takes to view an object, we can filter by that object ID later. I’m attempting to create a plugin that exposes a custom API that, when given a site ID and an object ID, returns the number of page views and file downloads associated with that object (Matomo already seems to be tracking the download events with the custom variables I created in the way I would expect). My question for you all is how I can get those numbers via the API? Can you give me an example of how you could get page view and file download events associated with a specific custom variable?

Hi,

While I can’t help you with your main question, maybe these two things help you:

Hey, I saw your post and thought I would provide the method used in the site I measure.

We set the the site ID (from taxonomy) as a custom dimension for every hit. This means we can use the that custom dimension to filter any other dimensions and metrics - be that number of users, page url visits, outlink clicks and/or file downloads. Works well in the reports, API and scheduled emails too. Best of luck :slight_smile:

1 Like

Louis, we are struggling with defining our trackEvents and Custom Dimensions in such a way that we can filter against other dimensions. Can you please elaborate on what you are doing because it sounds like we might be able to utilize your approach.