Can I track (as a goal) when a video is watched?

Rookie question I’m sure but I know (just enough) to get into trouble!

Like to setup a tracking goal to show how many times a video is viewed from a webpage. Can someone walk me through an example - I’m not a scared ( :wink: ) code it if I have to.

Thanks in advance…

Hi there,

For this you must first be able to track Events from your video player. Event Tracking - Analytics Platform - Matomo

Then you can create a goal where the goal is to receive an event with a particular Action or Name or Category which matches the event you’ve sent from your player. Track Goals and Measure Conversions - Analytics Platform - Matomo

Maybe someone else will be able to assist you further :slight_smile:


I have the same problem. As I am not a programmer i did not succeed to track events from my videoplayer.
This is how I start the video. The analytics i have been using until today is still there.

What do I have to put in there? And what do I have to put elsewhere?

Thanks in advance


I’m wondering the same, both for video and audio, specifically on WordPress…I certainly do see pages viewed, but I equally need to know is what content is played. To me, these media plays and the time/order they’re clicked in, are just as important as full page view data.

I’m tried using and tweaking the documentation tracking code in both the official Piwik WP plugin (which is useless, because for some odd reason you can tweak all sorts of other things, but can’t actually edit it to insert the tracking code), along with a third party version (which will).

Still, in both cases, no media events are tracked at all, whether using the stock HTML5 audio/video players WP now provides (JQuery-based), or the other HTML5 or Java-based third-party plugins offered there.

The only exception is when playing content via WP’s players in a playlist, and only in a specific situation - a media played event appears as a download if you explicitly click on an item in a WP media playlist. While this helpful in a crude way, no clicks on play/pause/forward/rewind or next/previous track buttons are caught, nor are position marker timings when this happens.

Like the previous poster, I’m not a coder, but thanks to a computer science degree and a decade in QA at an audio software company, I’m computer-savvy enough to perform advanced level config stuff like doing my own Piwik and WordPress installs on my hosting company’s server - so I kinda know a bit about what I’m doing here - but even then, I am finding the documentation on how to set up event tracking puzzling and lacking lesser-geek understandable detail.

The only third party solution where I’ve seen this leveraged properly (and for free, no less!) appears to be with the Leanback Player, which has it’s own Piwik plugin. Sadly, it doesn’t appear to be working - apparently the developer hasn’t updated the app or his plugin code since Piwik 1.x back in 2012…

C’mon, guys - some more detailed help on would really be appreciated on this, whether via improved code within Piwik to actually catch these kinds of things, or at least with improved, more human-readable documentation and real-world code samples (i.e. working examples on globally widely-used platforms like WordPress, which would be a great start not just for me, but many others I’m sure).


Hallo SGNYC,

I have a link for you:

Here is the code from the exampl:


I have put my own data into it, and the video is playing.

What I dont now is: How is the function “function trackVideo(goal)” called with my own goal. I tried to put the name of my goal into it, but no success.

May be you get further than me.



I believe I am the same as the posters above in that I am technically very savvy but not a coder (though I have dabbled). It would help to have some real walkthroughs for a few of the great features of Piwik for people like us. Anyway I believe I have cracked the problem asked in this post, and my website now tracks play events which I have used this to create goals:

To begin, my video is loaded in html5 with the code below:

<video id="video1" controls>
            <source src="video/video1.webm" type="video/webm" />
            <source src="video/video1.mp4" type="video/mp4">

Now, how did I track this? Well, I tried a number of things but the one that worked for me was by using an (Easy!) javascript function and putting it into onplay="" in the video tag. See below for the added ‘onplay’ bit, the “trackingFunction()” can be whatever name you choose for your function:

<video id="video1" controls [b]onplay="trackingFunction()"[/b]>
            <source src="video/video1.webm" type="video/webm" />
            <source src="video/video1.mp4" type="video/mp4">

When a visitor clicks play on the video it then runs the function ‘trackingFunction()’. This is the bit below (I put it my website just after the above tag):

function trackingFunction() {
	_paq.push(['trackEvent', 'Video', 'Play', 'VideoNameHere']);

You can rename each of the ‘Video’, 'Play, ‘VideoNameHere’ parts as you like. These are the names of the ‘category’ (video in this case), ‘Action’ (play in this case) and ‘event name’ (name of the video in this case) which will show up in Piwik.

The final part was to test it and then add a goal.

This is what worked for me and I hope it helps!


how to set goal after added these codes…where we get videos tracking details

We now have a Media Analytics plugin that tracks Videos & Audio!

More information is available here: The plugin gives useful insights into media / video / audio analytics and adds many new reports, widgets and segments to Piwik.

Works with HTML5 video & audio, Vimeo and YouTube out of the box. Support for other players can be added easily and is documented in the developer docs. We are also happy to add support for more players upon request, please ping us. After installation the plugin will in most cases directly start tracking data see the setup guide

For a full list of features check out . Docs are available at FAQ, User Guide, Developer docs

This post was flagged by the community and is temporarily hidden.