Using reporting API to get most visisted pages from part of my website?

Hi!

I’m trying to use the Action.getPageUrls to get the most visited pages from part of a web site and I’m trying to use the segment to filter but it does not come out the way I want

This is my call:

http://my-matomo-website/?module=API&method=Actions.getPageUrls&idSite=2&period=month&date=2025-11-30,2025-12-30&format=JSON&showColumns=nb_visits,nb_uniq_visitors&filter_limit=20&expanded=1&flat=1&segment=pageUrl==http://my-sit.se/subpage-1/subpage-2/

I want the most visited pages from subpage-2 and further down in the structure but the above does not do it.

Would like stat on these:
http://my-site.se/subpage-1/subpage-2/page-1
http://my-site.se/subpage-1/subpage-2/page-2

But these are also included and not wanted:
http://my-site.se/subpage-1/page-22/
http://my-site.se/news/2025/11/my-news 

I also get stats for the start page.

Is there anyway to get want I want using somw kind of filter?

Thanks and Happy New Years!

/Kristoffer

1 Like

Hi there,

Segments in Matomo are visit-based. This means when you apply a segment that filters by specific page URLs, Matomo will include all visits that contain those page URLs—but it will also show all actions from those visits, including other pages viewed during the same visit.

This is why you will be seeing pages like http://my-site.se/subpage-1/page-22/
http://my-site.se/news/2025/11/my-news

As you are using the API, you can use the parameters for filter_column, filter_pattern and filter_sort_order.

An example using the demo version of Matomo can be seen below.

This query would filter by pageURLs that contain liveaboard and sort them in descending order.

You could adjust these parameters to suit your query.

https://demo.matomo.cloud/index.php?module=API&method=Actions.getEntryPageUrls&idSite=1&period=day&date=yesterday&format=JSON&token_auth=anonymous&filter_column=label&filter_pattern=liveaboard&filter_sort_order=desc&showColumns=nb_visits,nb_uniq_visitors

Thanks Jason for the claryfication, I think this is what I need.