Track when user listens to a sound file

Hi,

That’s very odd. I am indeed from Austria, but I can’t really explain that.
When you open the network tool of your browser you can see a request to http://www.imatri.se/analytics/piwik/piwik.php?e_c=MediaPlayer&e_a=Play&e_n=DWYNoMoreINMCrossToBear&idsite=1&[many_more_parameters]

Could you please enable debugging, so I can check the issue:
https://developer.piwik.org/api-reference/tracking-api#debugging-the-tracker
Simply add

[Tracker]
debug = 1

to the config/config.ini.php

I can see that somethin happens yes. But no output anywhere in the Piwik interface. I added the two lines in ini-file. Don’t know how to use that but it seems you have some possiblity to read it? It’s there now.

Hi,

The debug setting causes piwik to respond with a verbose log to the request sending the event data. (e.g. http://www.imatri.se/analytics/piwik/piwik.php?e_c=MediaPlayer&e_a=Play&e_n=testsong&idsite=1&rec=1&r=228283&h=20&m=50&s=26&url=http%3A%2F%2Fwww.kallmansistersband.se%2Fsound.php%3Flang%3D3%26page%3D3&urlref=http%3A%2F%2Fwww.kallmansistersband.se%2Fstart.php%3Flang%3D3%26page%3D1&_id=2d66dda044c8b607&_idts=1512503230&_idvc=1&_idn=0&_refts=0&_viewts=1512503230&send_image=1&pdf=1&qt=0&realp=0&wma=0&dir=0&fla=0&java=0&gears=0&ag=0&cookie=1&res=1920x1080&gt_ms=122&pv_id=An0vD2 )

But I can’t find anything odd and I think I have now ran out of ideas.
If you don’t see any lines with an arrow like this one (:event:) in the visitor log, I can’t think of any reason for this.
grafik

Oh yes, I can see the small arrows, in my former visits today as well. So small I didn’t mind hover them before but doing that reports the media player event. But just at a single recent visitor together with the icoms I talked about.

So great in the way that we know the event is passed. Not that great that Piwik don’t pass them to the section where alla events should be collected, so you can see how many times a file was play over the time. As is now I can just see that YOU used it during this specific visit.

Strange if Piwik didn’t display that kind of data. Can it be that they want you to spend some money on the MediaTracker add-on tp get useful stats about that? The best conclusion I have.

I also see that you tried all the players. Just the first song has an ID. Found arrows that included the name given to that file. The other arrows reported just MediaPlayer.

So a small step, but if you can’t get some summary of those events you can’t use it to evaluate. I guess. Perhaps Piwik is buffering and display them later? Not problably so.

So sorry I didn’t noticed the arrows as something important. I didn’t expect them to represent events at all.

PS. How on earth did you get “testsong” into the script?

Will have to leave as it’s time to calibrate the monitors. Perhaps we have reached as far as possible. No more reason to keep the debug-tracker on?

You can disable it as the data is definitely being recorded and saved. The display of the data can be fixed later.

Done. And added names to the other audio players as well. Did you by last comment indicate some hope of getting the total stats reported?

Will try to find some way to track the two videos on the page as well as the downlodag links. I can recall some of the code we looked upon earlier was realted to that.

Have a nice evening Lukas. Was in Austria and Wien a couple of days in September. First time in Wien after lots of visits in the alps :).

Success Lukas!

Look at this! Seems like there is som built-in delay. The events that was just an arrow icon yesterday has now been sorted in the Event section. Everything else seemed to update real-time but some post are obviously buffering before a report is generated.

How nice. Let’s see if I can find out a way to tag my videos as well as the download links.

You last snippet (after edited) was the way to go.

1 Like

To track the number of times visitors have listened to specific songs on a page using Matomo, you can utilize event tracking. Modify your code to trigger a custom Matomo event each time a song is played. For example:

javascriptCopy code

document.addEventListener("DOMContentLoaded", function(event) {
  var audioTags = document.querySelectorAll("audio");

  audioTags.forEach(function(audio) {
    audio.addEventListener("play", function() {
      _paq.push(['trackEvent', 'Song', 'Play', audio.getAttribute('data-song-name')]);
    });
  });
});

This script assumes each audio element has a data-song-name attribute for identification. Adjust it based on your HTML structure. This way, you’ll have event data in Matomo representing each time a song is played.

1 Like