Reporting API - Grab pageview data for a specific URL

Is there a way to use reporting API to grab a page view data for a specific URL? What I was planning on is to display the pageview data for a specific page on the page itself.

I have the same question, with the same target. I would like to insert a graph of visits history on the page itself. Can this be done?

I tried to look at the code how Matomo is inserted into the page, but my attempts only return the root level analytics to the page. Is there a means to define the visuals level (URL or page title) other than root in the inserted widget?

Another route could be to define a segment containing only that URL/title, and showing such segment in the inserted widget. Is that possible to do (I have not managed to add a limitation of a segment to inserted widget).

-Tapio-

And here is a reply to myself. Of dear, it is possible! You can add segments to widgets in a similar fashion as segments are used in API calls. I was not able to find a mention about this on documentation about the segments, and when I first tried to use a ready-defined segment (by its name) with a widget, it did not work. But then, just by change, I tried to build the segment from components into the widget URL along the same rules as you use segments in API calls, and lo-and-behold, it did work! Happy camper here!

Be careful, by default segment is not filter.
https://matomo.org/docs/segmentation/#about-segments-in-matomo
https://matomo.org/faq/how-to/how-do-i-get-matomo-segments-to-behave-as-a-filter/

Thanks, this was a good and important notification!

A follow-up question. If I widgetize a “transitions” widget, I can get the top line data rows and the image for the root page of my web site. I can also add a segment to define e.g. page title or page url, but that only gives the top data rows (“Top 100 labels” and pageview count thereof). However, the transition image does not show, but only gives “Exception - NoDataForAction”. Why is this?

Sorry I don’t understand your last issue…
Can you check in the network tab of your browser developer tool (F12) if there is another error? Also check the console log?
Can you provide an example of what you want to achieve, with some examples of URLs, etc. Try also to use the demo.matomo.cloud/ to illustrate your example…

The following code is from Administration → Platform → Widgets, and opens the “Transitions” widget for the root of my web site, as expected (sorry I cannot give you a snapshot of it. Also the URL is not real):

https://myserver.com/index.php?module=Widgetize&action=iframe&disableLink=0&widget=1&moduleToWidgetize=Transitions&actionToWidgetize=getTransitions&idSite=X&period=day&date=yesterday&disableLink=1&widget=1

I then try to do the same thing to a subpage (as if I browsed to a subpage in the interactive mode, by adding a segment (this works for the graph of daily visits):

https://myserver.com/index.php?module=Widgetize&action=iframe&disableLink=0&widget=1&moduleToWidgetize=Transitions&actionToWidgetize=getTransitions&idSite=X&period=day&date=yesterday&disableLink=1&widget=1&segment=pageTitle==myPageTitle

this latter returns the number of pageviews that matches the segment, but shows no flowchart of where people come to page and where they navigate to.

In the Matomo demo instance:

  1. https://demo.matomo.cloud/?module=Widgetize&action=iframe&disableLink=0&widget=1&moduleToWidgetize=Transitions&actionToWidgetize=getTransitions&idSite=1&period=day&date=yesterday&disableLink=1&widget=1
  2. https://demo.matomo.cloud/?module=Widgetize&action=iframe&disableLink=0&widget=1&moduleToWidgetize=Transitions&actionToWidgetize=getTransitions&idSite=1&period=day&date=yesterday&disableLink=1&widget=1&segment=deviceType==tablet,deviceType==Smartphone

Both are working (I changed the segment to one existing at demo.matomo.cloud).

Are you sure the segment you use is defined in Matomo?
(Please note again, that the segment you are using just looks on visits that hit the selected page during the whole visit, if you did not change the default behavior of segments)

Note also that if you changed the behavior of segments, you should maybe invalidate old data before looking on graphs…
https://matomo.org/faq/how-to/faq_155/

Thanks again. I see it works, now I just would need to understand how. The first URL has no segment defined at all, yet it goes to “/jobs” sub-page. And the second url points to segment defining some device types, and goes to “/cart”. There seems to be a big hole in my understanding how segmentation works.

Segmentation

If you define a segment “Page = page A”, then:

:x: Considering the whole visit Page B (just one page visit): No page will appear in the segment
:x: Considering the whole visit Page B → Page C: No page will appear in the segment
:white_check_mark: Considering the whole visit Page A (just one page visit): The page will appear in the segment (as you expected)
:white_check_mark: Considering the whole visit Page A → Page B: All pages will appear in the segment (as you probably did not expect)
:white_check_mark: Considering the whole visit Page B → Page A: All pages will appear in the segment (as you probably did not expect)

This widget (the second link above has a segment “Page = jobs” defined, right? If yes, where does the definition come from, as I cannot see it in the URL calling that widget?

I think it is not possible tore-select the page that is displayed (by default the most viwed page?)
@innocraft any idea?

@TapioLinkosalo The link you mention: https://demo.matomo.cloud/?module=Widgetize&action=iframe&disableLink=0&widget=1&moduleToWidgetize=Transitions&actionToWidgetize=getTransitions&idSite=1&period=day&date=yesterday&disableLink=1&widget=1&segment=deviceType==tablet,deviceType==Smartphone

Is a specific type of widget called the “Transitions” widget. In this case there is no segment defined for “Page = jobs”, instead it simply shows the transitions for all pages and you can change the selected page using the dropdown:

This widget will allow you to switch between the top 100 labels by default, but its not possible to define a specific URL to be selected in the widget link. In other words this widget will always show by default the page with the most pageviews for the segment that is applied to it.

The only way that you would be able to add a widget to a page to get statistics for just that one page would be to create a Custom Report and add a filter for that specific page: https://matomo.org/docs/custom-reports/#report-filter