What are some popular PHP stat tracker options that can be self-hosted on a server?

One popular PHP stat tracker option that can be self-hosted on a server is Matomo (formerly Piwik). Matomo offers comprehensive analytics features and allows users to have full control over their data by hosting it on their own server. Another option is GoAccess, a real-time web log analyzer that provides detailed statistics on web traffic. These self-hosted PHP stat trackers can help website owners track and analyze visitor data without relying on third-party services.

// Sample code for setting up Matomo on a self-hosted server
// Make sure to replace 'MATOMO_URL' and 'MATOMO_SITE_ID' with your own Matomo URL and site ID

<script type="text/javascript">
  var _paq = window._paq || [];
  _paq.push(['trackPageView']);
  _paq.push(['enableLinkTracking']);
  (function() {
    var u="//MATOMO_URL/";
    _paq.push(['setTrackerUrl', u+'matomo.php']);
    _paq.push(['setSiteId', 'MATOMO_SITE_ID']);
    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+'matomo.js'; s.parentNode.insertBefore(g,s);
  })();
</script>