How to log page unload event


(Élodie Petit) #1

Hi all!

I am trying to integrate Piwik javascripts to my own web site. Logging works fine without problems but I also want to log page unload events server side.

What I understand from the piwik.js file, when the page unloads, Piwik doesn’t send a log request to server instead it calls a plugin method named “unload”.

How can I send a log for the unload event?

Thanks in advance.


(vipsoft) #2

What I understand from the piwik.js file, when the page unloads, Piwik doesn’t send a log request to server instead it calls a plugin method named “unload”.

Right. However, there are a few internal changes in piwik.js for the upcoming Piwik 1.1 release, and the plugin methods should not be considered official/stable yet.

How can I send a log for the unload event?

You could try something like:

tracker = Piwik.getTracker();
Piwik.addPlugin('myUnloadHandler', {
    load: function() { /* stub */ },
    log: function() { },
    click: function() { },
    goal: function() { },
    unload: function() { /* do something here */ }
});