fisharebest / webtrees

Online genealogy
https://webtrees.net
GNU General Public License v3.0
486 stars 301 forks source link

No matomo javascript code in header #4890

Open gatonero opened 1 year ago

gatonero commented 1 year ago

I'm trying to activate matomo in my webtree installation. I activated the modul but I don't see any matomo code in the header in the source files. My generated modul config is:

<script type="text/javascript">
    var _paq = window._paq || [];
    _paq.push(['trackPageView']);
    _paq.push(['enableLinkTracking']);
    (function() {
        var u="https:\/\/stammbaum.matomo.cloud\/";
        _paq.push(['setTrackerUrl', u+'piwik.php']);
        _paq.push(['setSiteId', "1"]);
        _paq.push(['setUserId', "ChristophS"]);
        var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0];
        g.type='text/javascript'; g.async=true; g.defer=true; g.src=u+'piwik.js'; s.parentNode.insertBefore(g,s);
    })();
</script>

v 2.1.17

fisharebest commented 1 year ago

I don't see any matomo code in the header in the source files.

Tracking is only added to the genealogy pages - not the administration pages.

gatonero commented 1 year ago

Jumping to genealogy pages as administrator and other minor privileged users doesn't show the matomo javascript calling from my LAN. But users from WAN get now monitored.

fisharebest commented 1 year ago

When you access the site from your LAN, do you use the same URL?

I guess that matomo only runs when the URL matches the value set in the snippet.

fisharebest commented 1 year ago

Did you set the DNT (do not track) header in your browser?

webtrees will obey this header.

gatonero commented 1 year ago

Good hint! So I deactivated DNT but nevertheless in the source code I don't see the matomo script. Surprisingly it works when visitors come from outside (WAN).

fisharebest commented 1 year ago

it works when visitors come from outside (WAN).

My guess is that the tracking script itself doesn't run when accessed locally.

This answer on stack-overflow appears to confirm this. Tracking local access needs to be specifically enabled.

https://stackoverflow.com/questions/13688749/piwik-localhost-tracking

gatonero commented 1 year ago

This is my supposition also. I tried the suggested solution on stackoverflow but that didn't work. Under [General I entered

trusted_hosts[] = "localhost"
trusted_hosts[] = "192.168.178.100"

in matomos config.ini.php.

But this doesn't affect webtrees to generate the script code as I assumed. Also it would be nice to have some more configuration options in webtrees for matomo e.x. for Tracking Manager etc.