Can I get the page views of a specific URL using the API?

Hi there,
can I get the page views of a specific URL using the Matomo API?

Example URL:

Can I get the page views that page received in a specific time frame (e.g. April 1 to April 20)? Are there any examples?

Also, can I get that page views count separated by the user’s language?

Thanks a lot !! :slight_smile:

yes, you can get page view of specific url using the api provided by some web analytics tools. Google analytics or example, provides an API that you can use to retrieve page views data for a specific URL. to do this , you need to make a request to API endpoint with appropriate parametre.

Yes, you can retrieve the page views of a specific URL using the Matomo API. Matomo (formerly known as Piwik) provides a comprehensive API that allows you to access various analytics data.

To get the page views for a specific URL within a specific time frame, you can use the Matomo Reporting API. Here’s an example API request you can use:

[type or paste code here](https://your-matomo-domain/matomo.php?module=API&method=Actions.getPageUrl&,2023-04-20&format=JSON&token_auth=YOUR_AUTH_TOKEN)

Replace your-matomo-domain with the domain where your Matomo installation is hosted. Replace with the URL for which you want to retrieve the page views. Replace YOUR_SITE_ID with the ID of the Matomo site you’re interested in. Replace YOUR_AUTH_TOKEN with your Matomo authentication token.

The period parameter is set to range to specify a custom time range, and the date parameter is set to 2023-04-01,2023-04-20 to specify the time frame from April 1 to April 20, 2023.

To separate the page views count by the user’s language, you can add the segment=visitorLanguageCode!%3D'' parameter to the API request:

[type or paste code here](https://your-matomo-domain/matomo.php?module=API&method=Actions.getPageUrl&,2023-04-20&segment=visitorLanguageCode!%3D)

This will give you the page views count for each language separately.

Make sure to replace the placeholders (your-matomo-domain,, YOUR_SITE_ID, YOUR_AUTH_TOKEN) with the appropriate values for your setup.

Note: The API request examples assume you’re using the JSON format for the response. If you prefer a different format, you can adjust the format parameter accordingly (e.g., &format=xml for XML format).

Remember to ensure you have the necessary permissions and access to the Matomo API in order to retrieve the desired data.

To retrieve the page views count for each language separately from Matomo (formerly known as Piwik) using the API, you can make a request to the Actions.getPageUrls API endpoint. Here’s an example request using placeholders for the necessary values:

sqlCopy code


In this request, you need to replace the following placeholders:

  • your-matomo-domain: Replace this with the domain where your Matomo instance is hosted.
  • YOUR_SITE_ID: Replace this with the ID of your website in Matomo.
  • YYYY-MM-DD,YYYY-MM-DD: Replace these with the start and end dates of the desired period in the format YYYY-MM-DD.
  • YOUR_AUTH_TOKEN: Replace this with your Matomo authentication token. You can find or generate this token in your Matomo instance by going to “Settings” > “Personal API access tokens”.

Once you replace the placeholders, you can send the request to retrieve the page views count for each language separately. The response will contain the data in JSON format, including the page URLs and their corresponding page views.

Please note that Matomo offers various API methods and parameters to retrieve different types of data. The example provided focuses on page views by URL, but you can explore other API endpoints and parameters to obtain different metrics or customize the data you retrieve. Refer to the Matomo API documentation for more details on available endpoints and their usage.