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