Skip to content

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

Closed as not planned

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.

Activity

  1. acelaya commented on Nov 13, 2026

    @acelaya
    Member

    Shlink should already be sending the full short url (or visited url for orphan visits) to Matomo.

    Isn't there a way to filter out/segment by domain in Matomo?

  2. acelaya commented on Nov 21, 2026

    @acelaya
    Member

    I have been exploring this, and I think I won't be supporting per-domain matomo keys, because it makes things over complicated for something most people won't need.

    It is also not very flexible if in the future there's a need to split visits in different matomo instances by some other indicator (by visit type, by destination, etc.).

    Instead, I have been exploring custom segmentation options in matomo. I will support a way to send so known custom dimensions, in matomo terminology.

    Shlink will support sending three custom dimensions:

    • Domain
    • Is orphan (true or false)
    • Visit type (valid_short_url, invalid_short_url, base_url, regular_404)

    Dimensions need to be configured in your Matomo instance. It assigns an ID to each one of them, and you will have to provide those IDs to Shlink for it to set them (via env vars or configuration).

    imagen

    This approach allows to add more custom dimensions in the future if new needs appear, in a more convenient way.

    Matomo let's you then use dimensions as a way to segment your visitors, so you would be able to see visits for one domain only, for example.

    imagen imagen
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions