API Connector Documentation
Import Matomo Data to Google Sheets
In this guide, we’ll walk through how to pull data from the Matomo API directly into Google Sheets, using the API Connector add-on for Sheets.
We'll first get an API token from Matomo, and then set up a request to pull in data from Matomo to your spreadsheet.
Contents
- Before You Begin
- Part 1: Get Matomo API Token
- Part 2: Pull Matomo API Data into Sheets
- Part 3: API Documentation
Before You Begin
Click here to install the API Connector add-on from the Google Marketplace.
Part 1: Get Your Matomo API Token
- Log in to Matomo and click on the Administration gear in the main menu.
- In the Admin menu, click Personal > Security
- At the bottom of the page click Create New Token
- Describe the purpose of our token (e.g. "get data in Sheets") and submit the form. You should now see a page containing your API token.
- Keep this token handy as you'll need it in a moment. Congrats! You're now ready to use the Matomo API.
Part 2: Pull Matomo API Data into Sheets
For this example, we'll get a list of visits by country. Where it says your_Matomo_domain
, substitute in the location of your Matomo instance, e.g. if you self-host Matomo at yoursite.com/matomo
, enter yoursite.com/matomo
. Enter in your own API token with it says your_token
.
- Open up Google Sheets and click Extensions > API Connector > Open > Create request.
- In the request form enter the following:
- Application:
Custom
- Method:
GET
- Request URL:
https://your_Matomo_domain?module=API&method=UserCountry.getCountry&idSite=1&period=day&date=today&format=json&filter_limit=-1&token_auth=your_token
- Application:
- Create a new tab and click Set current to use that tab as your data destination.
- Name your request and click Run. A moment later you’ll see Matomo analytics data populate your sheet.
Check the documentation for the full list of available dimensions and metrics. Specify the data table using the method
parameter. The Events methods accept an extra secondaryDimension
parameter to fetch an extra event column, e.g. https://your_domain?module=API&method=Events.getCategory&secondaryDimension=eventAction&flat=1&idSite=1&period=month&date=today&format=json&filter_limit=-1&token_auth=your_token
would retrieve a table of event categories and actions.
Part 3: API Documentation
Official API documentation: https://developer.matomo.org/api-reference/reporting-api
Hi,
I want to get monthly matomo data automatically importet per API.
The API is working but I don´t get my data set automatically for the last month.
Are there any ideas how to get it working. Thank a lot in advanced.
The export url looks like this:
module=API&format=CSV&idSite=1&period=month&date=2022-07-01&method=Actions.getPageUrls&flat=1&translateColumnNames=1&language=de&token_auth=xxxxxxxxx&filter_limit=-1&convertToUnicode=0
Hi there, sorry, I didn't totally understand the question. Are you getting the wrong data when you run your request, or are you asking how to get your data automatically?
If you want to run requests automatically, you can set up scheduling as shown in this article: https://mixedanalytics.com/knowledge-base/api-connector-scheduling/. Let me know if that answers your question, or please elaborate further and I'll be happy to answer here.