Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Let users assign a specific matomo URL / trusted host to a specific site #14583

Open
tsteur opened this issue Jun 28, 2019 · 1 comment
Open
Labels
Enhancement For new feature suggestions that enhance Matomo's capabilities or add a new report, new API etc.

Comments

@tsteur
Copy link
Member

tsteur commented Jun 28, 2019

Say you have multiple trusted hosts configured in Matomo:

  • foo.example.com
  • bar.example.com
  • analytics.example.com

They are all used for different purposes/sites. When we currently get SettingsPiwik::getMatomoUrl() the last used URL will be used. This will be used for example in scheduled reports. When then sending out the email, one of those URLs will be used randomly depending on which one was used last.

However, a user might want to force the usage of a specific trusted host when accessing a site and maybe wants to force the usage of a specific host in emails etc.

The same applies to Tag Manager containers which contains a preview URL when the preview mode is enabled. Depending on which URL was used last, the preview URL will use that trusted host. However, you may want to enforce loading the preview file from a specific trusted host for a specific site.

Like you want to configure:

idSite = 1 use foo.example.com
idSite = 3 use bar.example.com
idSite = 8 use analytics.example.com

something like this could be done for example in the config.ini.php or in config.php or it could be even simpler that we configure it in the options DB .

Basically we would need a new parameter like SettingsPiwik::getMatomoUrl($idsite = false) and when a specific idSite is given, then we first look if there's a matomo URL for the specific site and if not, behave as usual where we return the last used URL.

Internally this could look like: check option_name=piwikUrl_$idSite. If it exists, use that URL.... if it doesn't exist, check piwikUrl. A user could configure it by setting the correct entry in the option table. As this would be rarely used, a setting in the config might be too much.

Note: if the stored URL in piwikUrl_$idSite (eg piwikUrl_3) is not a trusted host, we would also fallback to piwikUrl.

I reckon with tests this can be done in like 4-8 hours as not too much logic needs to be changed. We would also change a few usages of SettingsPiwik::getMatomoUrl() to pass the idSite as an argument when the idSite is available.

@tsteur tsteur added the Enhancement For new feature suggestions that enhance Matomo's capabilities or add a new report, new API etc. label Jun 28, 2019
@mattab mattab added this to the Backlog (Help wanted) milestone Jul 4, 2019
@Starker3
Copy link
Contributor

BTW, this might also help for people who use Matomo Tag Manager with multiple different hostnames.
Currently whenever we load the MTM Preview Mode, it will use the piwikUrl from the database to fetch some of the resources (Logo, css files, etc)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Enhancement For new feature suggestions that enhance Matomo's capabilities or add a new report, new API etc.
Projects
None yet
Development

No branches or pull requests

3 participants