@alesiom opened this Pull Request on October 24th 2013

Adding a new function to piwik.js in order to be able to hook an external js file that could be fired when piwik.js is not fired.
E.g. to track scrolls, piwik.js is not fired. In order not to rewrite the entire getRequest method from piwik.js, add the possibility to hook an external js file which takes care of this new tracking and can then use the core to send the request.

@robocoder commented on October 25th 2013 Contributor

Custom event tracking is currently in development. https://github.com/piwik/piwik/tree/cevents

@alesiom commented on October 25th 2013

Ok, well;

I will be working on event visualization the next 4-5 months nearly full time so
My question is ; How far is Piwik 2.0 from a first release?
And is this version 1.13-a going to be released anytime, or is it just dropped?

@mattab commented on October 25th 2013 Member

2.0 is few weeks away from release. Great to hear you will work on Piwik, will you release it as open source or contribute back to Piwik core? if so please get in touch!

@alesiom commented on October 25th 2013

Oh good news !
Yes I will work on Piwik a lot. I guess I'll rather make a plugin and make it open source then working directly in the core.
I just installed Piwik 2.0 and see that there is (among others) a new ActionEvent class :)
Anyway, thanks for the great piece of news. I'll get back to you when I have something !

@alesiom commented on October 25th 2013

Dear Matt,
I don't know whether this is the best place to discuss about that, but I would like to present some ideas and some eventual "updates" I see for events.
First of all, I see that these event analytics on Piwik are very new (http://dev.piwik.org/trac/ticket/472), written couple days ago. So maybe everything I will discuss are things you already had planned/in mind, I am sorry if all this was already discussed.

I went through the new Piwik (2.0 branch cevents) and focused on particular on this event tracking. What came out is that you can track new events and they will be saved in the log_list_visit_action table. This means, each event has a URL and each Event is a new Action. From what I understand, an Action can be defined as a pageview. As you clearly explained it, an event will be defined by a category, an action, a name and a float (e.g: Movie, Play, Spirit Away, TimeSpent).
This is all good and I see great potential to it !

Now, what I have in mind as event tracking is not quite the same (and should maybe really be two separate things). Instead of trying to define what I define as an event, I'll focus on explaining my goal .
I want to create a new visualization tool, in which you don't display numbers and charts (like all the actual Analytic tools), but focus on what works and what does not work.
Basically give a better idea of user's journey on a website, and give hints to the Analytic tool user what to do next.
In order to get there, I should - among others - get the best idea of user's behavior (which is tricky!) and to do this, I want to track the actions + reactions of visitors. I'll give you here couple behaviors I would like to track

  • visitor clicks/touches somewhere but nothing happens (empty click)
  • visitor scrolls but nothing happens (empty scroll)
  • visitor scrolls for a long time without stop
  • visitor scrolls up and down quickly
  • etc

There are many other behavior patterns I would like to track, but this is just to give you an idea. (tracking computer + mobile events)

== What I tried/did ==
Following this idea, I created a plugin for piwik 1.13-a which generates (with the install method) a new table log_list_visit_events in which I can push all these events. The idea behind, is that events are linked to pageviews (log_list_visit_action). So a pageView can have plenty events.
I also created this table since I needed more than just to know the event-name, event-category and event-action. E.g: for a scroll I would need to know the duration of the scroll, the position of the mouse when the scroll happened, the html element that was underneath the mouse, the total distance the user scrolled, the absolute distance the user scrolled (users do sometimes scroll up and down quickly, so absolute != to total), etc etc.
Fortunately, there is a useful hook I could use (Tracker.newAction), to override the Action class and push all the data (which I send through POST requests, with a JSON structure) in my new table and not in log_list_visit_action. With this approach, Piwik is not bothered by new data which do not represent pageviews, and I have the freedom the save all data I need in the new table.
The only problem I had was to link my events to a particular page view. This is why I needed to get the getRequest method from Piwik.js (to recognize the visitor's cookie). With the small pull request version above, I have now my events linked the the right page views and I know which user behaved how. (right now I am only focusing on scrolls, but other events will come).
The second problem I had (and I still have), is that when using the hook ArchiveProcessing_Day.compute, I unfortunately have no control on my new table (at least I didn't find a way to!). This can be explained as in Segment.php, the generateJoins function defines the $knownTables (only log_visit, log_link_visit_action and log_conversion).

One solution to overcome that problem without touching the core would be to save data into cache instead of in the database (the heatmap plugin for piwik does that). I don't like that solution as I think it is slow (writing and reading) and I cannot link the data I have in my cache with the data in piwik's database (so I don't see how I could be able to link a certain behavior to a certain visit in log_visit).

All in all (and sorry for the long ticket), I don't know whether you would see a simple solution for a plugin (I am still discovering Piwik's structure, so maybe I missed something), or if you think this solution could be part of core, or something else :)

What should be kept in mind is that my tracking would be "heavy" since tracking everything, and should be a kind of tracking only used couple days/weeks to see some patterns appear. This approach is not meant to stay "on" all the time, but to focus really on user problems when a new product is out.

Anyway, I work on new ways to visualize data (user engagement on website/games) for my Master project, and I would love to be able to rely on Piwik's core instead of writing my own small analytic tool from scratch !

@mattab commented on October 27th 2013 Member

Wait a few days and check again my cevents branch, it's under development, and it should hopefully work for you. Let's discuss again in two weeks or so, stay tuned!

@alesiom commented on November 6th 2013

Dear Matt,
It looks like you developped a lot in this branch the last days. As you enabled the pluging by default in P2.0, I guess it is now in an advanced stage, which means I could work on it ? I am looking forward to it!
Thanks in advance for your feedback !

This Pull Request was closed on October 25th 2013
Powered by GitHub Issue Mirror