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

Are there any way to get correct URLs for matomo.js when running the UI from a different domain? #18327

Closed
mikkeschiren opened this issue Nov 16, 2021 · 3 comments
Labels
Potential Bug Something that might be a bug, but needs validation and confirmation it can be reproduced.

Comments

@mikkeschiren
Copy link
Contributor

I had problem to figure out which category to post this in.

Anyhow.
If I am running Matomo UI on a different domain like: dashboard.matomo.analytics is there a way to get the tracker scripts use another domain if they are only exposed on another sub domain (tracker.matomo.analytics) ?

Sure, the analytics people can change the domain from the tracker scipts to point to tracker.matomo.analytics instead dashboard.matomo.analytics - but there could many "human errors" if we do so.

So instead of



<!-- Matomo -->
<script>
  var _paq = window._paq = window._paq || [];
  /* tracker methods like "setCustomDimension" should be called before "trackPageView" */
  _paq.push(['trackPageView']);
  _paq.push(['enableLinkTracking']);
  (function() {
    var u="//dashboard.matomo.analytics/";
    _paq.push(['setTrackerUrl', u+'matomo.php']);
    _paq.push(['setSiteId', '1']);
    var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0];
    g.async=true; g.src=u+'matomo.js'; s.parentNode.insertBefore(g,s);
  })();
</script>
<!-- End Matomo Code -->

I want:

<!-- Matomo -->
<script>
  var _paq = window._paq = window._paq || [];
  /* tracker methods like "setCustomDimension" should be called before "trackPageView" */
  _paq.push(['trackPageView']);
  _paq.push(['enableLinkTracking']);
  (function() {
    var u="//tracker.matomo.analytics/";
    _paq.push(['setTrackerUrl', u+'matomo.php']);
    _paq.push(['setSiteId', '1']);
    var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0];
    g.async=true; g.src=u+'matomo.js'; s.parentNode.insertBefore(g,s);
  })();
</script>
<!-- End Matomo Code -->
@mikkeschiren mikkeschiren added the Potential Bug Something that might be a bug, but needs validation and confirmation it can be reproduced. label Nov 16, 2021
@Findus23
Copy link
Member

Hi,

I think an approach like https://forum.matomo.org/t/how-does-matomo-create-the-tracking-url-i-want-to-change-it/40262/2?u=lukas should solve your issue.

@mikkeschiren
Copy link
Contributor Author

Ah yes, thanks.

@mikkeschiren
Copy link
Contributor Author

Add this to: https://plugins.matomo.org/TrackerDomain

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Potential Bug Something that might be a bug, but needs validation and confirmation it can be reproduced.
Projects
None yet
Development

No branches or pull requests

2 participants