Using Reporting API, How can I Filter Page View Stats By Sub-Domain or Page Path?

Hi, I’m currently attempting to query the Matomo reporting HTTP API, but am struggling with creating “dimension” type filters on hostname and page path.

Can anyone please suggest any good examples of how I could do this sort of filtering in HTTP (or PHP) please?

Mind numbing details as follows.

We have a Drupal site with several hundred sub-domains. The content (and consequently the page paths) is usually same across the domains, the main differences are logos and styling.

We currently use Google’s Universal Analytics API (with PHP library) to extract data for reporting. The report defaults to 90 days and includes:

  • A line graph of total ga:pageviews (Matomo pageviews? nb_hits?) views over 90 days.
  • Various bar charts that show percentage traffic to top ga:pagePaths (Matomo Actions.PageUrl?)

The report default to data from all domains but can be filtered by ga:hostname (part of Matomo Actions.PageUrl?)

As you may know UA stops collecting data at the end of July 2023 and GA4 will only keep 14 months of data tops. So, I have setup a local copy of Matomo and believe I have successfully imported over 7 years data from UA which we really want to keep using.

However, I am struggling to reproduce the data extraction I do thru UA.

I can extract figures that seem similar to total page views doing this:,2023-03-08&format=JSON&token_auth=

However, when I add filter_column and filter_pattern to the URL I get 0 results.

Basically I would like create 2 “dimension filters”.

Firstly a filter where hostname is in a list of one or more sub-domains say:,

Secondly, filter where page path was in a REGEX like this:

If you read all this… I’m impressed :slight_smile:

Thank you.

Regards Brett

1 Like

Hi @brettsh
Do you want to “filter” data coming form GA, or data tracked by Matomo. ie do you have access to raw data in Matomo? Indeed:

The importer only imports aggregated report data, not the raw visit and action data. This means the Visitor Log,
Ecommerce Log and Segmentation features will not work for imported reports.
It also means that the Unique visitors metric and users metric for non-day periods (such as weeks and months periods) will not be available.

For new data, the solution would be adding a new dimension extracted from the host…