Skip to content

Support different Matomo Site IDs per API-key or domain (multi-service / multi-client / multi-tenant use case) #2588

@giacomotaormina

Description

@giacomotaormina

Summary

Description

Hi Alejandro,

I'm testing Shlink with multiple domains and I already use the multiple domains feature.

Each of my domains/services has its own separate Matomo instance (different Site ID for each).

However, the current Matomo integration in Shlink is global: only one MATOMO_SITE_ID environment variable is supported for the entire instance.
All visits from all domains end up tracked in the same Matomo site.

Current workarounds

  1. Assign custom tags to every short URL and create segments in each Matomo (manual and not scalable)
  2. Run separate Shlink instances per domain (loses the benefits of the native multi-domain feature and increases maintenance)

Proposed solution

Add support for a different Matomo Site ID per API key or per domain (preferred).

Possible implementations:

  • Add a matomo_site_id column to the domains table (abstract)

Use case

  • Domain serviceA.com → should send visits to Matomo Site ID 1
  • Domain serviceB.com → should send visits to Matomo Site ID 2
  • Domain serviceC.com → should send visits to Matomo Site ID 3
  • …and so on for each additional domain

This would allow each domain/service to have completely isolated analytics in its own Matomo instance without any manual segmentation or filtering.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    Status
    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions