Integrating Matomo Analytics with BookStack
Overview
Once Matomo is installed, you must link it to BookStack to begin capturing visitor data, page views, and search trends. This is done by injecting a small JavaScript snippet into the BookStack header.
1. Retrieve Tracking Code from Matomo
- Log in to your Matomo dashboard (e.g., http://192.168.0.152:8484).
- Click the Gear Icon (Administration) in the top right.
- On the left sidebar, navigate to Websites > Tracking Code.
- Ensure the correct website (e.g., "BookStack") is selected in the dropdown.
- In the JavaScript Tracking Code section, copy the entire block of code.
2. Apply Code to BookStack
- Open your BookStack instance and log in as an Administrator.
- Go to Settings (Gear icon in top navigation).
- Select Customization from the left-hand menu.
- Find the section labeled Custom HTML Head Content.
- Paste your copied Matomo script directly into the text area.
- Scroll to the bottom and click Save Settings.
<!-- Matomo Tracking Script Example -->
<script>
var _paq = window._paq = window._paq || [];
_paq.push(['trackPageView']);
_paq.push(['enableLinkTracking']);
(function() {
var u="//YOUR_SERVER_IP:8484/";
_paq.push(['setTrackerUrl', u+'matomo.php']);
_paq.push(['setSiteId', '1']);
var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0];
g.async=true; g.src=u+'matomo.js'; s.parentNode.insertBefore(g,s);
})();
</script>
3. Verification
- Open your BookStack homepage in a new tab.
- Navigate to the Dashboard in Matomo.
- Check the Visits in Real-time widget; your activity should appear within seconds.
Note: If you use an ad-blocker, you may need to disable it for your local domain to see your own tracking data.
No comments to display
No comments to display