# 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

1. Log in to your Matomo instance at `https://matomo.goonersnas.com/`.
2. Navigate to **Administration (Cog Icon) &gt; Websites &gt; Manage**.
3. Verify that the URL for Site ID 3 is set to `https://nc.goonersnas.com/`.

---

## 3. Nextcloud App Installation

1. Log in to Nextcloud as an **Administrator**.
2. Go to **Apps** and select the **Integration** category.
3. Search for **"Matomo Tracking"**. 
    - *Note: Avoid the legacy "Piwik" version (v0.13.0) as it is incompatible with v33.*
4. Click **Download and enable** (you may need to click "Allow untested app").

---

## 4. Connection Settings

1. Navigate to **Administration settings &gt; Additional settings**.
2. Locate the **Matomo Tracking** section.
3. Enter the following details:

<div id="bkmrk-matomo-server-url%3A-h" style="background-color: #f4f4f4; color: #000000; padding: 15px; border: 1px solid #ddd; border-radius: 4px; font-family: 'Courier New', Courier, monospace;">Matomo Server Url: https://matomo.goonersnas.com/ Site ID: 3 [x] Track file browsing [x] Track user id</div>*Note: Ensure the URL includes the trailing slash. Settings save automatically upon losing focus from the text fields.*

---

## 5. Verification

1. Open Nextcloud in an Incognito/Private browser window and navigate through a few folders.
2. Return to Matomo and go to **Dashboard &gt; Real-time &gt; Visitor Log**.
3. Look for active visits originating from your Nextcloud domain.

---

## 6. Troubleshooting &amp; Security

### Content Security Policy (CSP)

If tracking fails to report, you may need to whitelist your Matomo domain in the Nextcloud `config.php` file:

<div id="bkmrk-%27custom_csp_policy%27-" style="background-color: #f4f4f4; color: #000000; padding: 15px; border: 1px solid #ddd; border-radius: 4px; font-family: 'Courier New', Courier, monospace;">'custom_csp_policy' =&gt; "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;",</div>### 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.