I wrote a piece of code in java script that tracks the activities of the user on a particular page.I store them on certain variables and when user closes the page or navigates away from it I post them to the server.What I intended to do was to post to the server only once and so window.Unload event sounded as the natural one to use.I had to make certain sacrifices for this to work like making the request synchronous.
So what I wanted to know if what I did was good?Or is there any better way to accomplish this.I am looking for opinions here anything will be appreciated.
It will not work with all browsers,
If you want to track activities of users and don’t want to go for google analytics and want to keep data on your server you can choose following
http://piwik.org/docs/javascript-tracking/