Open Aaron-Gonz opened 4 years ago
Was able to get this working by disabling the plugin and placing the tracking code in my template's main.php file so tracking is added to every page.
Placed this in the top PHP section:
$user = $_SERVER['REMOTE_USER'];
Put the tracking code with setUserID snippet, per Matomo dev documentation, above tracker methods within HTML
, also in the main.php file. Code:<!--#################### Matomo ####################-->
<script type="text/javascript">
var _paq = window._paq = window._paq || [];
/* tracker methods like "setCustomDimension" should be called before "trackPageView" */
_paq.push(['setUserId', '<?php echo $user; ?>']);
_paq.push(['trackAllContentImpressions']);
_paq.push(['trackPageView']);
_paq.push(['enableLinkTracking']);
(function() {
var u="//dokuwiki.corp.intranet/analytics/";
_paq.push(['setTrackerUrl', u+'matomo.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.src=u+'matomo.js'; s.parentNode.insertBefore(g,s);
})();
</script>
<noscript><p><img src="//dokuwiki.corp.intranet/analytics/matomo.php?idsite=2&rec=1" style="border:0;" alt="" /></p></noscript>
<!--#################### End Matomo Code ####################-->
The plugin doesn't accurately read PHP contained within _paq.push in the tracking code area as it's currently written. Perhaps there's another way of going about this but Doku's documentation shows it's needed to grab the User ID.
Hopefully this saves people all the frustration I experienced trying to get this to work!
Looking at the Query String Parameters sent to Matomo from my DokuWiKi instance, it's evident the user_id or UID field is missing. The Matomo database in MySQL shows the user_id as NULL. The User IDs and Visitor logs also do not show a user ID.
I'm running Matomo version 3.14.0 and 2018-04-22b "Greebo" for Doku. My tracking code is as follows:
I've also experimented with adding with using several variations of
_paq.push(['setUserId', 'USER_ID_HERE']);
within the tracking code, and elsewhere, without any luck.Any help would be greatly appreciated!