Import Matomo data into Databricks
Databricks enables you to analyse Matomo data with data from across your organisation to answer questions in a wider business context.
You can ingest Matomo data directly from an On-Premise database or export Cloud data to a supported data warehouse before importing into Databricks. Once the data is available, you can write custom SQL queries, build dashboards, and combine analytics data with other business datasets.
This guide explains how to ingest Matomo data into Databricks from both Matomo On-Premise and Cloud instances.
Before you start
Ensure you have the following prerequisites in place:
- A Databricks workspace with permission to create SQL warehouses, notebooks, or connections.
- Permission to connect Databricks to your database or data warehouse.
- Access to your Matomo data source:
- On-Premise: database credentials for your Matomo MySQL or MariaDB database (or a read-only replica).
- Cloud: a configured Data Warehouse Connector exporting data to a supported destination, such as Google BigQuery, Snowflake or AWS bucket.
- Familiarity with SQL for querying analytics data.
Data ingestion options
There are different ways to bring Matomo data into Databricks and the approach depends on whether you use Matomo Cloud or On-Premise.
Option 1: Upload files (Cloud and On-Premise)
You can manually import one or multiple Matomo reports to create tables for analysis. When new data becomes available, you can re-import or refresh these reports to update the corresponding tables. This approach is best suited to smaller datasets and individual reports.
- Export one or more Matomo reports as CSV, TSV, or XLSX files.
- In Databricks, select Data Ingestion > Add data > Files.
- Upload the exported files and click Create table.
Option 2: Export Matomo Cloud data
For ongoing analysis, use the Data Warehouse Connector to export Matomo Cloud data to a supported data warehouse or storage destination.
- Enable and setup the Data Warehouse Connector in Matomo.
- Export your cloud data to a supported data warehouse by following the relevant guides:
- Export data to Google BigQuery
- Export data to Snowflake
- Copy exported data to my AWS bucket
- Once your Matomo data has been exported to your data warehouse or storage destination, connect Databricks using the appropriate connection method for your environment. For example, create a connection through Catalog explorer, a data ingestion pipeline, or another supported connector.
In Databricks, you can query the exported Matomo tables without copying the data or load the exported Matomo tables into Databricks-managed tables for transformation, reporting, or integration with other datasets.
Refer to the Databricks documentation for guidance on connecting to external data sources and importing data into Databricks.
Option 3: Connect to a Matomo On-Premise database
If you self-host Matomo, connect Databricks directly to the Matomo database for live queries, or ingest the required tables into Databricks for large-scale analysis.
- Depending on your Databricks environment, create a connection through Catalog explorer, a data ingestion pipeline, or another supported connector such as MySQL.
- Connect Databricks to your analytics database, reporting replica, or exported database.
- Use a read-only connection where possible, and avoid querying the production database heavily during peak traffic periods.
How to work with the data
Once your Matomo data is available in Databricks, you can create custom SQL queries, notebooks, and dashboards, or combine Matomo analytics with business datasets.
For example, identify marketing channels that generate customers with the highest lifetime value, or discover how customer retention varies by acquisition channel or landing page.
By combining behavioural analytics with data from across your organisation, you can build reports and dashboards tailored to your business requirements.