Privacy-friendly web analytics for Shopware 6.6/6.7 with full E-Commerce tracking, Klaro Consent Manager integration, and GDPR-compliant privacy features.
Why Matomo? Unlike Google Analytics, Matomo can be self-hosted on your own server, giving you complete control over your data. Combined with this plugin's privacy features, you can achieve:
| Feature | Description |
|---|---|
| Cookieless Tracking | Track visitors without cookies for reduced data collection |
| IP Anonymization | Configurable anonymization levels (1-4 bytes) |
| Do-Not-Track Respect | Honor browser DNT settings |
| Klaro Integration | Seamless integration with Klaro Cookie Consent Manager |
| E-Commerce Tracking | Product views, cart updates, order completions |
| Multi-Sales-Channel | Different configurations per Sales Channel |
| Heartbeat Timer | Accurate time-on-page measurement |
| Link & Download Tracking | Track outbound links and file downloads |
Installation via the Shopware Store is recommended. After purchase, you can install the plugin directly from the backend.
Add the private Composer repository to your shop's composer.json:
{
"repositories": [
{
"type": "composer",
"url": "https://packeton.markus-michalski.net"
}
]
}
Note: Repository credentials will be provided upon license purchase. Private repositories are managed via Packeton.
composer require mmd/matomo-analytics
When prompted for authentication, enter the credentials provided with your license.
bin/console plugin:refresh
bin/console plugin:install --activate MmdMatomoAnalytics
bin/console cache:clear
Update to the latest version:
composer update mmd/matomo-analytics
bin/console cache:clear
Plugin configuration in Shopware Admin:
Settings > Extensions > Matomo Analytics
| Setting | Required | Description |
|---|---|---|
| Matomo URL | Yes | Your Matomo installation URL (e.g., https://analytics.example.com) |
| Site ID | Yes | The Site ID from your Matomo installation |
| Enable Tracking | Yes | Master switch for all tracking |
| Setting | Default | Description |
|---|---|---|
| Cookieless Tracking | On | Track without cookies - reduces stored data |
| IP Anonymization | 2 bytes | How many bytes of the IP address to mask (192.168.xxx.xxx) |
| Respect Do-Not-Track | On | Honor browser DNT settings |
| Require Cookie Consent | Off | Only track after explicit consent (for cookie-based tracking) |
IP Anonymization Levels:
| Setting | Default | Description |
|---|---|---|
| Use Klaro Consent Manager | Off | Enable integration with Klaro Cookie Consent plugin |
| Klaro Service Name | matomo | Must match the service name configured in Klaro |
When enabled, the tracking script is blocked until the user consents via the Klaro modal. See Klaro Integration below.
| Setting | Default | Description |
|---|---|---|
| Enable E-Commerce Tracking | On | Master switch for E-Commerce features |
| Track Product Views | On | Track when users view product detail pages |
| Track Cart Updates | On | Track add-to-cart and cart changes |
| Track Orders | On | Track completed orders with revenue |
| Setting | Default | Description |
|---|---|---|
| Track Admin Users | Off | Include logged-in admin users in tracking |
| Enable Heartbeat Timer | Off | Accurate time-on-page measurement |
| Heartbeat Interval | 15 | Seconds between heartbeat pings |
| Track Outbound Links | On | Track clicks on external links |
| Track Downloads | On | Track file downloads (PDF, ZIP, etc.) |
If you're using the Klaro Cookie Consent plugin and want to require user consent before tracking, follow these steps:
In Settings > Extensions > Matomo Analytics:
matomo (or your preferred name)Navigate to Marketing > Klaro Cookie Services and create a new service:
| Field | Value |
|---|---|
| Technical Name | matomo |
| Title (EN) | Matomo Analytics |
| Title (DE) | Matomo Analytics |
| Description (EN) | Web analytics service that helps us understand how visitors use our website. Collects anonymous usage data. |
| Description (DE) | Webanalyse-Dienst, der uns hilft zu verstehen, wie Besucher unsere Website nutzen. Sammelt anonyme Nutzungsdaten. |
| Purpose | analytics |
| Required | No |
| Default Enabled | No |
| Active | Yes |
If you're NOT using cookieless tracking, Matomo sets cookies that should be deleted when consent is revoked. Add these cookie rules to the Klaro service:
[
{"pattern": "_pk_id", "path": "/"},
{"pattern": "_pk_ref", "path": "/"},
{"pattern": "_pk_ses", "path": "/"},
{"pattern": "_pk_cvar", "path": "/"},
{"pattern": "_pk_hsr", "path": "/"},
{"pattern": "MATOMO_SESSID", "path": "/"},
{"pattern": "piwik_ignore", "path": "/"},
{"pattern": "mtm_consent", "path": "/"},
{"pattern": "mtm_consent_removed", "path": "/"}
]
Note: If you're using cookieless tracking, Matomo doesn't set any cookies and you can leave the cookie rules empty. However, you may still need consent depending on your legal assessment.
type="text/plain" instead of text/javascripttext/javascript and executes itThe plugin automatically tracks E-Commerce events when enabled:
Tracked when a user visits a product detail page:
Tracked when the cart contents change:
Tracked on the order confirmation page:
For custom template integrations:
{# Check if tracking is enabled #}
{% if matomo_is_enabled(context.salesChannel.id) %}
{# Matomo is active #}
{% endif %}
{# Check if E-Commerce tracking is enabled #}
{% if matomo_ecommerce_enabled(context.salesChannel.id) %}
{# E-Commerce tracking is active #}
{% endif %}
{# Render tracking code (without script tags) #}
{{ matomo_tracking_code(context.salesChannel.id) }}
{# Render tracking code with script tags #}
{{ matomo_tracking_script(context.salesChannel.id)|raw }}
{# Render opt-out iframe #}
{{ matomo_opt_out_iframe(context.salesChannel.id, 'en', 'ffffff', '000000')|raw }}
You can add a Matomo opt-out option to your privacy policy page:
{{ matomo_opt_out_iframe(
context.salesChannel.id,
app.request.locale, {# Language #}
'ffffff', {# Background color #}
'000000' {# Font color #}
)|raw }}
This plugin is designed with privacy in mind:
| Aspect | Implementation |
|---|---|
| Cookies | Optional - cookieless tracking available |
| IP Storage | Anonymized (configurable level) |
| DNT Header | Respected when enabled |
| Consent | Klaro integration available |
| Data Location | Your Matomo server (self-hosted) |
For privacy-friendly tracking:
Important Legal Note: Whether consent is required for analytics tracking depends on your jurisdiction and specific implementation. Even with cookieless tracking and IP anonymization, many legal experts recommend obtaining user consent for analytics. Consult with a legal professional to determine the appropriate consent requirements for your specific situation.
bin/console cache:clearbin/console theme:compileIf your shop and Matomo server run on different (sub)domains (e.g., shop.example.com and analytics.example.com), the browser may block tracking requests due to missing CORS headers. In the browser's network tab, you'll see errors like blocked or ERR_BLOCKED_BY_CLIENT.
Solution: Add CORS headers to your Matomo server's Apache configuration:
# In your Matomo server's VirtualHost configuration
<IfModule mod_headers.c>
SetEnvIf Origin "^https://(.+\.)?example\.com$" CORS_ORIGIN=$0
Header always set Access-Control-Allow-Origin "%{CORS_ORIGIN}e" env=CORS_ORIGIN
Header always set Access-Control-Allow-Methods "GET, POST, OPTIONS" env=CORS_ORIGIN
Header always set Access-Control-Allow-Credentials "true" env=CORS_ORIGIN
</IfModule>
Replace example\.com with your domain (dots must be escaped with backslash).
After the change, reload Apache:
sudo apachectl configtest && sudo systemctl reload apache2
For Nginx:
# In your Matomo server's server configuration
set $cors_origin "";
if ($http_origin ~* "^https://(.+\.)?example\.com$") {
set $cors_origin $http_origin;
}
add_header Access-Control-Allow-Origin $cors_origin always;
add_header Access-Control-Allow-Methods "GET, POST, OPTIONS" always;
add_header Access-Control-Allow-Credentials "true" always;
type="text/plain" appears in the script tag (view source)Commercial License - Single installation license including:
See LICENSE file for full terms.
For questions and support:
Markus Michalski
Email: support@markus-michalski.net