Peertube and Plausible

Although has a focus on privacy, I’d like to at least get some basic information on how many people visit the site, and which articles get more than just a single view. I also like to have not a single visitor IP address in any log anywhere, which is why I opted to self-host Plausible.

Plausible offers a privacy-friendly alternative to Google Analytics and Matomo, giving a view on how many people visit a site and from which countries without collecting any PII (personal identifiable information).

Adding the Plausible script to my PeerTube instance however, turned out to be difficult. Searches turned up empty and there’s no plugin to add anything to your PeerTube headers.

I asked around on the PeerTube Matrix channel and got an excellent answer from Snack Capt, who showed me a way of adding the Plausible code without any plugin or hacking:

  1. Log on to your PeerTube instance as an administrator.
  2. In the Administration menu, go to “Configuration“, “Advanced Configuration“.
  3. Add the following code into the “custom JavaScript” field:
const script = document.createElement('script');
script.async = true;
script.defer = true;
script['data-domain'] = 'yourpeertube.domain';
script.src = 'https://yourplausible.yourdomain/js/plausible.js';

… replacing, of course, yourpeertube.domain and yourplausible.domain with the URL’s of your PeerTube and Plausible instances.

That’s it!

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.