Integrating Nextcloud Hub 28 with Matomo Analytics
This article outlines the steps to connect your self-hosted Nextcloud instance (v33.0.0+) to Matomo for tracking user activity and file browsing.
1. Prerequisites
- Matomo Site ID: Ensure you have created a "Measurable" for Nextcloud. For this setup, the Site ID is 3.
- Nextcloud Version: Hub 28 Winter (v33.0.0).
- App Version: Matomo Tracking (v1.0.0).
2. Matomo Configuration
- Log in to your Matomo instance at
https://matomo.goonersnas.com/. - Navigate to Administration (Cog Icon) > Websites > Manage.
- Verify that the URL for Site ID 3 is set to
https://nc.goonersnas.com/.
3. Nextcloud App Installation
- Log in to Nextcloud as an Administrator.
- Go to Apps and select the Integration category.
- Search for "Matomo Tracking".
- Note: Avoid the legacy "Piwik" version (v0.13.0) as it is incompatible with v33.
- Click Download and enable (you may need to click "Allow untested app").
4. Connection Settings
Matomo Server Url: https://matomo.goonersnas.com/ Site ID: 3 [x] Track file browsing [x] Track user id
Note: Ensure the URL includes the trailing slash. Settings save automatically upon losing focus from the text fields.
5. Verification
- Open Nextcloud in an Incognito/Private browser window and navigate through a few folders.
- Return to Matomo and go to Dashboard > Real-time > Visitor Log.
- Look for active visits originating from your Nextcloud domain.
6. Troubleshooting & Security
Content Security Policy (CSP)
If tracking fails to report, you may need to whitelist your Matomo domain in the Nextcloud config.php file:
'custom_csp_policy' => "default-src 'self'; script-src 'self' https://matomo.goonersnas.com; img-src 'self' data: https://matomo.goonersnas.com; connect-src 'self' https://matomo.goonersnas.com;",
Nginx Proxy Manager
Ensure that your Matomo proxy host does not have "Block Common Exploits" enabled if it interferes with the tracking .js delivery to external subdomains.