使用 Matomo API 获取以某个 URL 开头的前 10 个访问过的页面

Using Matomo API to get top 10 visited pages starting with a certain URL

对于博客,我试图从例如上个月获取前 10 个热门帖子。我想我应该从 Matomo 获取数据,因为它已经在跟踪访问并且有一个 API。不过,我以前从未使用过这个 API,所以我一直在阅读文档并尝试一些东西。我可以使用 Actions.getPageUrls 方法从 API 获取数据。但是,当我尝试使用 segment=^http://example.org/post 进行过滤时,我仍然从其他 URL 获取数据。看起来它在会话上进行过滤,并返回至少有 1 个页面符合过滤器的会话的所有数据。

我使用的完整 URL 是:http://example.org/matomo/index.php?&module=API&token_auth=12345&method=Actions.getPageUrls&format=json&idSite=1&period=month&date=today&expanded=1&segment=pageUrl%3D%5Ehttp%253A%252F%252Fexample.org%252Fpost。我也尝试过对段使用更少和没有 URL 编码,但这似乎没有什么区别。如果我使用不存在的 URL,我会返回一个空数组。

我是不是做错了什么?是否有不同的方法可以仅获取以 http://example.org/post 开头的 URL 的首页?还是我必须自己筛选数据才能得到我想要的页面?

我正在使用 Matomo 版本 3.13.5。

我明白了。没有必要使用 segment。这可以使用 flatfilter_columnfilter_pattern 参数来实现。

设置 flat=1 将使所有页面在单个数组中返回,而不是分层返回。

使用 filter_columnfilter_pattern 我可以过滤结果。

我现在用的URL是:http://example.org/matomo/index.php?&module=API&token_auth=12345&method=Actions.getPageUrls&format=json&idSite=1&period=month&date=today&flat=1&filter_column=label&filter_pattern=%5E%2Fpost%2F。这正是我想要的。

未编码的模式是 ^/post/,因此这将过滤掉任何不以 /post/ 开头的页面。