# Linking Matomo as a source - Docs

![](https://res.cloudinary.com/dmukukwp6/image/upload/texture_tan_9608fcca70)

![](https://res.cloudinary.com/dmukukwp6/image/upload/texture_tan_dark_a92b0e022d)

Let AI connect your sources for you

Skip the manual setup — run this in your project and the wizard auto-detects your databases and APIs and connects them to PostHog.

`npx @posthog/wizard warehouse`

[Learn more](/wizard.md)

![PostHog Wizard hedgehog](https://res.cloudinary.com/dmukukwp6/image/upload/wizard_3f8bb7a240.png)

**Alpha release**

This source is currently in **alpha**. The interface and available tables may change.

Connect your Matomo instance to pull web analytics data into the PostHog data warehouse. Works with both Matomo Cloud and self-hosted instances.

## Adding a data source

1.  Go to the [sources tab](https://app.posthog.com/data-management/sources) of the data pipeline section in PostHog.
2.  Click **\+ New source** and then click **Link** next to Matomo.
3.  Enter your **Instance URL** – for example, `https://myorg.matomo.cloud` for Matomo Cloud or your self-hosted URL.
4.  Enter your **Site ID** – the numeric ID for the site you want to import. You can find this in your Matomo instance under **Administration > Measurables/Websites > Manage**.
5.  Create an API token in Matomo under **Administration > Personal > Security > Auth tokens** and paste it into the **API token** field.
6.  Select the tables you want to sync, set the sync method and frequency, then click **Import**.

Once the syncs are complete, you can query your Matomo data in PostHog.

## Available tables

| Table | Description | Sync method |
| --- | --- | --- |
| visits | Raw visit log with visitor details, actions, and metadata | Incremental |
| visits_summary | Per-day aggregate visit statistics | Incremental |
| actions_summary | Per-day aggregate action statistics | Incremental |
| referrers | Per-day referrer breakdown | Incremental |
| countries | Per-day visitor country breakdown | Incremental |

**Incremental** tables sync only new or updated records on each run.

## Sync details

-   The first sync backfills up to 365 days of history for all tables.
-   The `visits` table uses `serverTimestamp` as its incremental cursor. Visits newer than one hour are deferred to the next sync to ensure their action lists are complete before storing.
-   Aggregate report tables (`visits_summary`, `actions_summary`, `referrers`, `countries`) walk one day at a time and re-pull a 3-day trailing window on incremental runs to account for late archiving. Records are merged on `_date` (and `label` where applicable).

## Configuration

| Option | Type | Required |
| --- | --- | --- |
| Instance URL | text | Yes |
| Site ID | text | Yes |
| API token | password | Yes |

## Supported tables

| Table | Description | Sync method | Incremental field | Primary key |
| --- | --- | --- | --- | --- |
| visits | The raw visit log from Matomo's Live API — one row per visit with its actions and visitor details. | Incremental, Full refresh | serverTimestamp | — |
| visits_summary | Per-day aggregate visit metrics from Matomo's VisitsSummary API. | Incremental, Full refresh | _date | — |
| actions_summary | Per-day aggregate action metrics from Matomo's Actions API. | Incremental, Full refresh | _date | — |
| referrers | Per-day referrer breakdown from Matomo's Referrers API — one row per referrer. | Incremental, Full refresh | _date | — |
| countries | Per-day country breakdown from Matomo's UserCountry API — one row per country. | Incremental, Full refresh | _date | — |

### Community questions

Ask a question

### Was this page useful?

HelpfulCould be better