Tracking Plays | The Argent Grub

Tracking Plays

10 Jun 2026

Press StopS

How to tell how many plays songs are getting when you self host?

After making the move to a self-hosted Faircamp instance to allow people to listen, download, and share my music at https://music.theargentgrub.co.uk/, I’m missing the Bandcamp dashboard that gave an overview of how many plays my songs were getting.

I’ve already set up non-intrusive web analytics on my site using Matomo - which can also be self-hosted. And I figured this could be a solution that others might use. (You could also buy a paid plan but that might be too expensive)

Matomo has a paid Media Analytics plugin available for self hosted versions but I can’t afford it.

Built in solution 1

Matomo has a Content Tracking option.

To make this work all I needed to do was

1) add

_paq.push(['trackAllContentImpressions']); 

to my existing matomo tracking code which is included in the site build (see the Pre-deployment section of my Faircamp blog post)

2) Add a data-track-content tag to sections of the generated Faircamp HTML

The ‘play’ button against a track uses HTML like the following:

<div class="track" data-duration="xxxxxx">

So it’s easy (sort of) to do a find and replace in the code (e.g. in Codium, or with a sed script):

Find: <div class="track" data-duration
Replace with: <div class="track" data-track-content data-duration

Once deployed, visited and clicked on, then over in your Matomo instance under Behaviour -> Contents you should start to see data showing up (there is lag - so be patient. I haven’t yet found good realtime ways to test)

The problem tho, is that the data is likely to show the long URLs to the audio files which is not necessarily all that easy to read. It would be easier if the track titles got passed to Matomo…

Built in solution 2

Sticking to a solution that adds tags to our HTML files, you can add the data-content-name= tag to HTML elements and Matomo will use the supplied name.

The problem here is we need to be inside the Faircamp code to render that name with a tag when the site is built.

There are two other tags that could also be used:

 data-content-piece
 data-content-target

I forked the faircamp code and this commit shows how I altered it.

However to use it - I now need to build and install this version of faicamp (Note it’s version 1.7.0 that I have altered)

I also use the Docker image provide by n3wjack normally - but I now need a Docker image that builds Faircamp from my alatered code.

So I forked the Docker image provide by n3wjack and altered it to build my own image.

Check out the README and Dockerfile to see if it makes any sense.

I could then build the site as before, and I now have tracking on some of the play buttons on my live site.

Problems

This is not a great solution for understanding how many plays I’ve had!

The approach above only tracks clicks on the play (and pause) buttons at the very front of the tracks. 2 clicks could be 2 plays or a play and a pause.

On Album pages there is also a Listen Button to listen to the whole album, and I’m not currently tracking that click. And obviously one click could mean the whole album is played or a single second, or anything in between.

Finally (I think) there is a player that comes up at the bottom of the site when a track is playing, and there are controls there to skip backwards and forwards through a play list, and play and pause - none of which is tracked.

It could be done with the method above and extend what I’ve done but is it worth it?

Other ideas

My idea above was that a regular faircamp user could easily sign up for a Matomo account and easily start to get some tracking recorded - built in solution 1 above should get you that - maybe it’s better than nothing, maybe not!

Built in solution 2 - is a pretty technical solution - although if you use Docker already, and can build a docker image it’s actually not much harder. This solution could also be refined by continuing to work on the Faircamp code. (Although with Faircamp 2 around the corner maintaining code etc could be hard work)

Other javascript solutions probably exist and Matomo does handle Events as well as content and so more digging around Matomo methods could be done. A custom javascript solution that works with Matomo could be a thing - and should be easy enough to add to a Faircamp build in the same way other code is - but it needs building!

There are solutions out there for (for example) Google Tag Manager - but this would fail the privacy respecting tracking that we can get with Matomo.

Maybe server logs is also a way to go, but that’s a whole new learning curve for me.

Ideas, questions, comments - contact me.