So, I’m working on a client site right now, with their own instance of Kirby and Matomo. Thing is, they want those things linked, so when somebody logs into the Kirby Panel, that data would show up in Matomo.
Also, moreover, they’d like the site to send over the username of the logged in person. In another site I’ve built in the past, the results look like this…
<script type="text/javascript">
var _paq = _paq || [];
<?php if ($context['user']['id'] != 0 && $context['user']['is_guest'] == false) {
echo "_paq.push(['setUserId', '" . $context['user']['name'] . "']);";
} ?>
_paq.push(['trackPageView']);
_paq.push(['enableLinkTracking']);
(function() {
var u="//site/analytics/";
_paq.push(['setTrackerUrl', u+'pwk.php']);
_paq.push(['setSiteId', '2']);
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>
So, basically what I’d like is to have that script block load on every panel page, and also to conditionally send _paq.push(['setUserId', {{username}} ]);
whenever the user is actually logged in.
Thoughts?