xref: /webtrees/resources/views/modules/matomo-analytics/snippet.phtml (revision 54c1426ef019dee75f3e7bd3fa3ca06d5420591a)
1<?php
2
3declare(strict_types=1);
4
5use Fisharebest\Webtrees\Contracts\UserInterface;
6
7/**
8 * @var string        $MATOMO_SITE_ID
9 * @var string        $MATOMO_URL
10 * @var UserInterface $user
11 */
12
13?>
14<script>
15  var _paq = window._paq = window._paq || [];
16  _paq.push(['trackPageView']);
17  _paq.push(['enableLinkTracking']);
18  (function() {
19    var u=<?= json_encode($MATOMO_URL, JSON_THROW_ON_ERROR) ?>;
20    _paq.push(['setTrackerUrl', u+'matomo.php']);
21    _paq.push(['setSiteId', <?= (int) $MATOMO_SITE_ID ?>]);
22    var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0];
23    g.type='text/javascript'; g.async=true; g.src=u+'matomo.js'; s.parentNode.insertBefore(g,s);
24  })();
25</script>
26