Track user progress for an elearning system

We are in the process of designing a simple e-learning site, where our registered users and site administrators can see valuable statistical info about the user progress.

we want to track what topics they have visited the most, content “liked”, other user profiles visited, and maybe even add a reward system on top of that (points, badges, unlocking content) for finishing courses, watching videos, participating in discussion, or helping people.

Now I have been looking into Piwik as a potential analytics package for our website, and I know it is possible to track individual users by adding a unique “visitor_id” to the API calls. Is it possible for me to track and retrieve the information I described above using Piwik out of the box? Should I create my own plug in? Should I be looking at something different?

BTW this is just the same question asked here


You can use Custom Variable to track custom values: Using Custom Variables in Piwik (Tutorial) - Analytics Platform - Matomo

and this can be used for powerful things, also along with Segmentation: Segmentation - Compare segments of visitors - Analytics Platform - Matomo

but some of your requirements might need custom Plugin indeed. If you have a budget for this, get in touch with the Experts at

Thank you Matt for your answer.

I was aware that I could use custom variables and segmentation but I don’t really know what is the extent of the functionality of these features in the context of my project; based on your answer and the documentation/tutorials that you referred me to I have some follow up questions:

  1. I can track up to 5 custom variables on each page view, these variables must be the same from page to page? or can I track different things on different pages?

  2. If I can track different variables on different pages, can I just make two different calls to the API using the PHP sdk in order to extend the number of variables I want to track?

  3. can I delegate the job of calling the API to a worker queue that would process request one by one as they come?

  4. In the segmentation tutorial, it wasn’t apparent to me how I could get info on a user per user basis… maybe I just need to look at the documentation a little bit closer? here is the API call I have been trying to use to get the info about a single user but it only returns an empty value “[]”

I made a single API call that reports two variables test and gender

  1. the php sdk method doTrackPageView sends parameters via GET… why, should this be POST or this GET a requirement to report analytics?

Than you for the help.

Please try and then ask if you have any further questions. If you read the doc and find some info missing we can clarify the docs - let me know!

I am sorry, but I did take the time to read the documentation and try and debug the code.

From the documentation my questions 1, 2 and 5 are not clear.

  1. the docs you referred me to say

“In other words, if you create another custom variable and assign it INDEX 1, then it will start tracking this new variable.”

Yet it doesn’t address what happens after an API call has been made.
The document also says

" Remember you can track up to 5 custom variables per visit and/or up to 5 custom variables per page view."

But once again is not clear if these variables can be different from page to page.

I tested the following call

$user_id = '0000000000000002';
$piwikTracker->setVisitorId( $user_id );
$piwikTracker->setCustomVariable(1, 'test2', 'for test 2', 'visit');
$piwikTracker->setCustomVariable(2, 'test3', 'for test 3', 'visit');
// Sends Tracker request via http

$piwikTracker->setVisitorId( $user_id );
$piwikTracker->setCustomVariable(1, 'test4', 'for test 4', 'visit');
$piwikTracker->setCustomVariable(2, 'test5', 'for test 5', 'visit');
// Sends Tracker request via http

and it only recorded test4 and test5, but if I create a second object for test 4 and 5 it records all actions. I expanded my test to 10 different variables and I was able to record them all. Although there is very odd behavior once I try to record more variables in different pages mainly variable names get changed, or are removed completely from the “custom variable” list.

In question 4 you can see how I tried based on the documentation example here and all I’m getting is an empty response.

Finally question 5 I changed the method doTrackPageView to send the request using post. it seem to record the variables just fine, but I’m not sure if this is a proper way to do it.

Some clarification is appreciated.

Replace ‘visit’ with ‘page’ for scope page.

Also to test properly, it’s better to wait for some time between 2 requests because piwik will only track different pages when the time is different (here the 2 page views are sent at the same second so only one wil lbe tracked)

Finally question 5 I changed the method doTrackPageView to send the request using post. it seem to record the variables just fine, but I’m not sure if this is a proper way to do it.

if it works, it’s perfect!