Event tracking

I would like to see some sort of javascript event tracking added to Piwik. I don’t mean Goals because the things I’m thinking of are too minor to be considered Goals.

For example:
A user clicks a certain check box
A user uses the search bar
A user only makes it to a certain place in a form and gives up.

We can’t really see these things with the typical visit/action model. Sometimes we can use custom variables for some of these things, but that’s a bit hackish, and we only get 5.

I would love to have all those extra events attached to a specific visit because there is a wealth of knowledge there. It would also be nice to segment our data based on these events, but that seems like a large project.

I would write a plugin for this, but I don’t see a way to do this outside of altering piwik.js and the core.

Agreed. This is the one big thing that is missing from Piwik.

It should modeled after the Google Analytics Event tracking:

As per Piwik 1.5, you can use Custom Variables for each page view. Then, you can see a counter of each name and value. This is quite basic reporting, but it is definitely V1 of “Event Tracking” in Piwik :slight_smile:

For example, on a given page view, you could have the custom variables:
index N - Custom_var_name = Custom_var_value

index 1 - Category = Videos
index 2 - Click = Play
index 3 - Name = “Amélie” trailer
index 4 - Duration = 45

Then you can get reports, Top “categories”, “Top Clicks”, list of best “Names”, etc.

it is not as advanced as Google Analytics but should help with all basic tracking needs. Any thoughts?

That could be a poor mans event tracking, but there is still the fact that events often happens multiple times on the same page. I don’t think multiple events on one page view would work, but I could be wrong. ??

Anyhow. This is still a pretty lousy solution, and not the intention of the custom variables.

Can we please have real event tracking?

I like to see that too, to track which portion of website are used.
For the moment I track it as outlink in this way:

<a href="/some/link/from/sidebar.html" onClick="javascript:piwikTracker.trackLink('/sidebar/Topic 1', 'link');"> Topic 1 </a>

<a href="/some/link/from/footer.html" onClick="javascript:piwikTracker.trackLink('/footer/Link', 'link');"> Link </a>

so I have at least some numbers about usage of some website modules via Actions > Outgoing Links.
But it cheats stats for outgoing links I think.

I’d really like to see javascript event tracking also.
My goal is tracking and analyzing streaming media usage. I can develop a JWplayer plugin for Piwik. Such a plugin is written in javascript and would track events like play, pause actions in a video and length played. It would be similar to the Google Analytics plugin (Publisher Support | JW Player) for JWplayer which depends upon GA’s ‘trackEvent’ functionality. Would be great to have a similar plugin for Piwik.

tkuipers, check out this post: How to track a goal in Piwik from the JW Video Player

I would like to know if it is possible to track adsense clicks with piwik on my site. If not, this will be an awesome event tracking feature.


I’d love to see event tracking in piwik!

I would like to see this as well and I think it’s pretty easy to accomplish. What we need for this is an extra set of actions. Lets call them custom actions. These actions can be treated the same as pageviews, external links and downloads.

All we need is to add some extra action types (lets say max 10?), add a few menu items and the reporting. These actions can then be logged using:
piwikTracker.trackLink(‘footer/link’, ‘customaction_1’);

I’m already working on a plugin for this but the current structure of the actions kind of prevent this from working since there is a check on the action type (at least when debugging is enabled). So when debugging is disabled it works but I’m worried that this check will later be added even if debuging is disabled which would make the plugin worthless. And even then I think it’s much better to integrate this direclty into the current Actions structure.

Any dev that would consider this? I’m willing to make it but only if I’m sure it will be accepted into the main core or that my plugin will keep working.

See suggestion in: 301 Moved Permanently

Yes, that could be a workaround but it’s still not what I need. Is there any reason why the actions wouldn’t be extended a bit?

Why is it not what you need exactly ?

We hope to document officially to use cusotm variable scope page as it works really well for us!

Well, suppose I want to be able to record clicks in a certain area of my site. These clicks do not refresh the page but do trigger some ajax functions.

In our case we don’t want these to be logged as a new pageView since its not a page view but we do want to count how many times this happened.

The case mentoined in my previous post (header/footer links) could work with page variables although I still think the pageview is then counted twice.

The last argument I have (but I know this is a bogus one ;)) is that I feel that it really belongs to the actions page since it is the actions you want to track and not the visits.

Our plugin is almost complete so I think our problem is then solved. But I still think it would have been a good addition to Piwik and very easy to include in the current Actions.


We have some odd scripts that tracks 10+ events, so if we are going to use Piwik in the future, it needs to handle that too…


I’ve got a problem with tracking Event on Piwik, with Firefox and Safari …:confused:

When there is a href=“myURL.html”, the onclick=“javascript:_paq.push([‘trackPageView’, ‘whatIwant2Track’]);” doesn’t work ! But it works very well with Chrome/IE.

So, when I remove the href=“myURL.html”, it works.
If I remove this href but I add a location.href=‘myURL.html’ here:
onclick="javascript:_paq.push([‘trackPageView’, ‘whatIwant2Track’]); location.href=‘myURL.html’;"
It doesn’t work …

Could you help me please ? :slight_smile:


  • My Link
  • Thanks in advance


    No offence, but the current state of Piwik’s customized action/events logging is really holding Piwik back, imho. I feel like many of the other analytics software/companies have customized logging that is much more versatile than Piwik’s, and I would really like to see Piwik grow in this area. If Piwik’s action logging can be used in advanced ways that I am not seeing, then I apologize. Looking forward to reading your docs on the subject, matt.

    One thing I would really like to see is more multivariable logging/filtering/retrieval such as logging the creation of objects and actions performed on those objects. (e.g. logging the creation of a news article, comments on, favorites, adding to collections, shares, etc and visualizing them over time). A news article is a bad example because it can have a static-ish page, but think about something like twitter posts, Pinterest posts, and user interactions that most definitely can’t be tracked the same way a url that never changes does.


    @Selby We agree and would like to improve Custom event tracking in Piwik. If you have thoughts, or budget / sponsoring, get in touch.

    @matt, all I really have to give is time. If you have time to help a new dev get acquainted with the Piwik codebase, I’d love to give it a go to see if we could build a solid proposal for a more advanced custom logging system. Since there are no solid opensource alternatives, I am about to start working on a logging system to do activity feeds and basic analytics for the company where I work, so I’ve given it some thought. Is #piwik on freenode the main method of communication between developers?

    Fabian from the team is on freenode but he’s the only one I think. Otherwise you can use piwik-hackers mailing list, or the forum here, I’ll do my best to help!