WordPress Training
Ressources

Automatically export Matomo data to Google Sheets

Matomo Analytics Dashboard

Matomo is an excellent analytics solution — GDPR-friendly, ownership-friendly, data-sovereign. What Matomo does not do well out of the box: flexibly processing data further in spreadsheets. If you send a weekly traffic report to management, maintain a monthly SEO audit table, or simply want to work through your data with the filtering boldness of Google Sheets, you have to marry Matomo and Sheets. Three approaches work in practice, all with a different setup effort. For the fundamental question of whether Matomo or Google Analytics is the better choice in 2026, read my post on Google Analytics vs. Matomo — this one assumes you are already using Matomo.

Prerequisites: A running Matomo instance (cloud or self-hosted), API access (see below), a Google account with Sheets access. Time for setup: 30–90 minutes per method.

Why Sheets instead of the Matomo UI?

Before I get technical, a quick question: what is this actually useful for?

  • Reporting to stakeholders. Managers want tables, not dashboards that require a logged-in mouse action. A weekly auto-populated Sheet table with the five most important metrics is gold.
  • Cross-tool comparison. If you want to show Matomo data alongside Search Console data, Mailchimp stats and CRM conversions, Sheets is the glue.
  • Your own scoring system. Do you want to calculate a „page quality score“ from bounce rate, session duration and conversion rate? Pivot tables, FORMULAS, nested IFs — that is Sheets territory, not Matomo territory.
  • Historical archive. Some Matomo Cloud plans have data retention limits. Whoever persists important metrics in Sheets will still have them in five years.

What Sheets does not replace: the Matomo UI itself. Funnel analyses, session recordings, heatmaps — you continue to do those in Matomo. Sheets is the aggregation and distribution layer.

Method 1: Matomo Reporting API + Apps Script (step by step)

The most robust and flexible method. Setup time: 30–60 minutes.

Step 1: Create a Matomo auth token.

In Matomo → Personal settings → Security → „Authentication tokens“ → „Create new token“. Permission: read-only on the relevant sites. Note down the token (you only see it once).

Step 2: Build the API URL.

The Matomo Reporting API has a very consistent structure:

https://IHR-MATOMO.example.com/index.php
  ?module=API
  &method=VisitsSummary.get
  &idSite=1
  &period=day
  &date=last30
  &format=JSON
  &token_auth=IHR_TOKEN

Important parameters:

  • method — what you want to query (e.g. VisitsSummary.get, Actions.getPageUrls, Referrers.getKeywords)
  • idSite — the site ID (you can see it in the Matomo backend)
  • periodday, week, month, year, range
  • date — e.g. last30, 2026-05-01,2026-05-31
  • format=JSON — returns structured data, ideal for Apps Script

Step 3: Set up Google Apps Script.

In Google Sheets → Extensions → Apps Script. The following script (basic skeleton):

function fetchMatomoVisitsSummary() {
  const url = 'https://IHR-MATOMO.example.com/index.php'
    + '?module=API&method=VisitsSummary.get'
    + '&idSite=1&period=day&date=last30'
    + '&format=JSON&token_auth=' + getToken();

  const response = UrlFetchApp.fetch(url, { muteHttpExceptions: true });
  const data = JSON.parse(response.getContentText());

  const sheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName('Matomo');
  sheet.clearContents();
  sheet.appendRow(['Date', 'Visits', 'Unique Visitors', 'Bounce Rate', 'Avg. Time']);

  Object.entries(data).forEach(([date, metrics]) => {
    sheet.appendRow([
      date,
      metrics.nb_visits || 0,
      metrics.nb_uniq_visitors || 0,
      metrics.bounce_rate || '0%',
      metrics.avg_time_on_site || 0
    ]);
  });
}

function getToken() {
  return PropertiesService.getScriptProperties().getProperty('MATOMO_TOKEN');
}

Step 4: Store the token securely. Apps Script → Project settings → Script properties → MATOMO_TOKEN as the key, your token as the value. This way the token is not in the code.

Step 5: Set up a trigger. Apps Script → Triggers → „Add new trigger“ → fetchMatomoVisitsSummary → time-driven → daily at 06:00.

Done. From now on your Sheet updates automatically every morning with the last 30 days of visit data.

Method 2: Looker Studio as a bridge

If you want to script less and click more.

Setup:

  1. In Looker Studio (formerly Google Data Studio) → „Data sources“ → „Matomo Connector“ (community connector).
  2. Establish a connection with Matomo: URL + auth token.
  3. Create a data source (e.g. „VisitsSummary“).
  4. In Looker Studio, create a report or pull the data directly into a table.
  5. In Looker Studio → „File“ → „Export to Google Sheets“ — either one-off or via scheduled email.

Advantages:

  • No code
  • Visualizations „for free“ in Looker Studio
  • Scheduled email reports straight out of Looker
  • Self-service for non-technical users

Disadvantages:

  • Community connectors vary in quality — some have not been updated in two years
  • Looker Studio reports are not as dynamic as native Sheets logic
  • Slow with large amounts of data

For many smaller setups (solo freelancers, small agencies) this is the pragmatic solution — no Apps Script overhead.

Method 3: Plugins and SaaS bridges

There are two kinds of plugins:

WordPress plugins (when Matomo is integrated via WordPress):

  • „Matomo Analytics — Ethical Stats“ (the official plugin from Matomo) does show data in the WordPress dashboard, but Sheets export is not built in.
  • „Connect Polylang for Matomo“ and similar specialized plugins target other use cases.

SaaS bridges:

  • Coupler.io — paid (from USD 49/month), click-based integration between Matomo and Google Sheets. Worth it if you want to integrate several data sources.
  • Supermetrics — the big player. Very expensive (from EUR 99/month), but enterprise-grade.
  • Funnel.io — similar to Supermetrics, somewhat cheaper.

My advice for most readers: Method 1 (Apps Script) is the best investment of 60 minutes that you can maintain yourself permanently and without ongoing costs. SaaS bridges make sense when you want to orchestrate 5+ data sources and have no appetite for scripting.

Sources of error: auth token, CORS, rate limits

Across more than twenty setups, I have seen the following errors again and again:

1. Auth token with too many rights. For the Sheets integration, create a dedicated token with read permission only for the specific site. Never use admin tokens — if you ever pass on the tab while it is open, the risk is too high.

2. URL encoding errors. If you use filters with special characters (e.g. segment=pageUrl=@/blog/), they must be correctly encoded. UrlFetchApp.fetch in Apps Script usually expects clean URLs — encodeURIComponent() is your friend.

3. CORS problems (not in Apps Script, but in the browser). If you want to call the Matomo API from a browser web app, you need CORS headers in Matomo. Apps Script is not affected by this, because the call runs server-side.

4. Rate limits. Matomo Cloud has (as of 2026) no official API rate limits, but for self-hosted setups on weak hardware, large reports (e.g. pageviews over 365 days with segmentation) can overload the server. Solution: smaller chunks, shorter date ranges.

5. Timestamp inconsistencies. Matomo uses UTC. If you work with local times in Sheets, off-by-one-day effects can occur. In Apps Script, convert before writing with Utilities.formatDate(date, 'Europe/Vienna', 'yyyy-MM-dd').

Practical example: weekly traffic report

A concrete setup that I have running for three clients:

Sheet structure:

  • Tab „Raw“: Apps Script data from Matomo (updated daily)
  • Tab „Weekly“: calculated weekly totals via QUERY()/SUMIFS()
  • Tab „Dashboard“: charts and KPI boxes that reference „Weekly“
  • Tab „Email“: prepared weekly text with & and TEXT()

Apps Script triggers:

  • Daily at 06:00: update the Raw tab
  • Every Monday at 09:00: additionally run sendWeeklyEmail(), which sends an email to the stakeholders from the Sheet

The weekly email then automatically contains: the top 5 pages of the week, a comparison with the previous week and the previous month, new referrers, technical anomalies (e.g. a suddenly increased bounce rate on a landing page).

Anyone heading in the same direction — using data better, getting more out of analytics — should also take a look at my post on free SEO analyses for beginners. And for the big picture on SEO + WordPress: WordPress SEO basics.


Would you like help with the setup?

If you do not want to set up the Apps Script setup for your Matomo instance yourself, I can set it up for you in 2–3 hours — including handover training, so that you can add new reports yourself. Just write me a short note about what you want to track.

Request setup: Get in touch

Tags

AnalyticsAutomatisierungGoogle SheetsMatomoReporting