# Using Matomo with WordPress

> Track visitors on your WordPress site with Matomo analytics using a plugin or by adding the tracking code to your theme.

Source: https://helpcenter.ruachost.com/wordpress/guides/using-matomo-with-wordpress/

**Matomo** (formerly Piwik) is an open‑source analytics platform that provides detailed visitor statistics for your website. On **ruachost.com**, you can integrate Matomo with WordPress either by using a plugin or by editing your theme directly.

## Why Use Matomo?

- Full control over your analytics data (self‑hosted).
- GDPR‑compliant and privacy‑focused.
- Provides detailed visitor insights (traffic sources, search terms, conversions).
- Alternative to Google Analytics with no data sharing.

## Method 1: Use a WordPress Plugin (Recommended)

1. **Install Matomo** on your hosting account (via Softaculous or manual installation).
2. Log in to WordPress as administrator.
3. Go to **Plugins → Add New**.
4. Search for **WP‑Matomo (WP‑Piwik)**.
5. Click **Install Now**, then **Activate**.
6. Go to **Settings → WP‑Piwik**.
7. Enter your Matomo URL (e.g., `https://yourdomain.com/matomo`).
8. Enter your **Auth Token** (generated in Matomo under *Administration → Personal → Security*).
9. Save changes → WordPress will now connect to Matomo.
10. Enable tracking under **Enable Tracking tab** → Select **Default tracking**.

✅ You can now view visitor statistics directly in the WordPress dashboard.

## Method 2: Edit the Theme Directly

1. Log in to your Matomo account.
2. Go to **Administration → Websites → Tracking Code**.
3. Copy the full JavaScript tracking code.
4. Log in to WordPress as administrator.
5. Go to **Appearance → Theme Editor → footer.php**.
6. Paste the tracking code just above the closing `</body>` tag.
7. Save changes.

✅ Matomo will now track all pages on your WordPress site.

## Important Notes

- Editing the theme directly may cause changes to be lost during theme updates. Use a **child theme** to avoid this.
- Plugins are easier to manage and update, but may add slight overhead.
- Always test tracking after setup to confirm data is being collected.
