PDA

View Full Version : Mouse Tracking



Fidodo
October 30th, 2008, 08:40 PM
Does anyone know of any mouse tracking APIs out there? i.e. tracking mouse movements of a user session for data collection. If there's nothing out there, I can come up with something but I don't want to develop something that's already around and better implemented.

theCodeBot
October 30th, 2008, 10:40 PM
Not sure exactly what you're asking, so I'll give you my best guess:


//This code will keep the last 100 mouse locations
var lastMouse:Array = [];
stage.addEventListener(MouseEvent.MOUSE_MOVE,addMo vement);
function addMovement(e:MouseEvent):void {
if(lastMouse.length>100){lastMouse.shift();}
//Removes oldest after 100 mouse locations are collected
lastMouse[lastMouse.length] = new Point(e.xmouse,e.ymouse);
//Here is where you could react to certain general locations
}

You can make that much larger if you like, but I think 100 is more than sufficient.

Fidodo
October 31st, 2008, 01:41 AM
I know how to implement something like this. I was more curious if there was a robust version of this for data analysis. Analyzing trends, and movements over an entire user session. Something like what's mentioned here http://johndyer.name/post/2006/08/01/Mouse-Tracking-Beyond-Analytics.aspx but for flash instead of the general website with javascript. I want a more overall user movement analysis tool, which would be more complex than a simple array of movements. I mean you would also have to keep track of timing and clicks, and interactions with different states of the website. Enough to actually recreate a user session, and store it for later viewing and analysis. Also, it would need to be able to detect trends of multiple users, so I'm thinking of something pretty complex. I could develop this, but you can see that it would be alot of work, although it would be invaluable for many developers.

theCodeBot
October 31st, 2008, 08:01 AM
I see. You intend to figure out what parts of your website users use the most and least? In that case, I would probably not track mouse positions on mouse move, but instead just every time a click or maybe rollOver is called, and store those to an array that maxes out at 400 roughly.

I'd say keep this array in the form of object, listing items clicked, mouse position, and times, and keep a separate object listing of how often each item has been used or clicked, perhaps of how often certain videos are viewed (including when they are completely viewed versus watched 15 seconds).

Then I'd send the data at the end of the session to a PHP that in turn sends it to a database. When another PHP page reads the database in, it calculates averages for each general IP (Can't remember the correct name for that. The first 2 groups of digits) and spits them out at you. I.E., "For video A, 1000 visits have taken place averaging 95% of the video watched for 75.144.xx.xxx (Somewhere in the U.S.A)"

benarent
October 31st, 2008, 11:13 AM
Hey, I'm also trying to do the same thing. But more intressted in how to play my logs back.

I found this tutorial intressting. http://www.wonderhowto.com/how-to/video/how-to-record-play-back-user-interaction-with-a-flash-movie-260729/view/

I'm already tracking every click and sending it to a server, What is the best way in which i can use this data to 'play' the interface back to me?

Below the Time, and Instance name of each movieclip clicked.


10:49:57 goBackElement
10:50:07 goBackElement
10:50:24 launchWriteMessage
10:50:25 personIcon1
10:51:34 sendMessage
14:05:02 launchBroadcastScreen
14:05:08 goBackElement
14:05:11 launchBroadcastScreen
14:05:13 goBackElement
14:05:18 launchBroadcastScreen
14:16:31 goBackElement
14:52:55 yesReadMessage
14:53:04 goBackElement
14:53:10 goBackElement
14:53:14 launchReadMessage
14:53:18 goBackElement
14:53:19 launchWriteMessage
14:53:21 personIcon4
14:56:07 sendMessage
15:08:10 launchCreateChat
15:13:38 launchWriteMessage
15:13:40 personIcon4
15:14:22 sendMessage
15:19:36 yesReadMessage
15:19:46 goBackElement
15:19:49 goBackElement
15:19:52 launchWriteMessage
15:19:55 personIcon4
15:20:27 sendMessage
15:20:39 launchWriteMessage
15:20:42 personIcon2
15:21:32 sendMessage
15:21:52 yesIWouldLikeToJoin
15:22:05 volPlus
15:22:05 volPlus
15:22:06 volPluscheers
Ben

theCodeBot
October 31st, 2008, 04:28 PM
Ben, since you have the time data, and since this is something we'd want to do (For example, if the PHP page returns the average data, it can thus create an average user session, right?), it's easy to play the session back, and if it plays back a calculated average... all the better!

I would say, get the timed events loaded, and put a clock in the corner of the screen, which starts at the time of the first event and has play/pause/seekbar controls much like a movie. It starts with a movieclip that looks like the mouse in the center of the screen, and at the time fro each event, tween the mouse clip to each event's location and send an artificial mouse click event to the actual movie, so it behaves like it did for the user. During longer periods if time between events (greater than 5 seconds), the click flashes to grab your attention and speeds on to the next event, fast-forwarding movies if need be. The controls should also have a next/previous event control.

I'll post the best example I can come up with as soon as I'm done coding it, I'm working on it now, since this really intrigues me and I would like to use something like it someday soon.

Fidodo
November 2nd, 2008, 03:43 AM
I see. You intend to figure out what parts of your website users use the most and least? In that case, I would probably not track mouse positions on mouse move, but instead just every time a click or maybe rollOver is called, and store those to an array that maxes out at 400 roughly.

I'd say keep this array in the form of object, listing items clicked, mouse position, and times, and keep a separate object listing of how often each item has been used or clicked, perhaps of how often certain videos are viewed (including when they are completely viewed versus watched 15 seconds).

Then I'd send the data at the end of the session to a PHP that in turn sends it to a database. When another PHP page reads the database in, it calculates averages for each general IP (Can't remember the correct name for that. The first 2 groups of digits) and spits them out at you. I.E., "For video A, 1000 visits have taken place averaging 95% of the video watched for 75.144.xx.xxx (Somewhere in the U.S.A)"

Actually, I'm working for the psych department at my college and I thought that having this kind of feature for the experiments I will be programming might be helpful to get some insight into the thought process of the subjects. Not only see what they do, but how they do it. So do they hesitate with their mouse movements? Do they predict where to move before hand? Things like that. I guess since noone has made anything like this for flash, I'll end up doing this myself. Actually, I don't even know if my professor would want anything this detailed yet, but I thought it would be interesting. I think the hardest part would be analyzing the data, not tracking it, since we would need to observe trends across a dataset of hundreds. If I end up doing this, and it comes out well I'll share it around for other people to use.

theCodeBot
November 2nd, 2008, 09:06 AM
Well, Like I said, since you'll be sending the data to a PHP/SQL backend (something I have minimal experience with, so I can only help you with the flash and some of the PHP), you can have the PHP calculate averages for certain user groups and pass them as XML to flash.

Then flash will have a dropdown to select from a list of average user groups, retrieved by the XML, and recreate the session by simply reading in timestamps and events and tween a cursor to the selected locations.

If you want to track hesitations, etc, that database is going to get very large, very quickly, so you may want to track only every 3rd movement and estimate the in-betweens to cut down on database size. I don't know how you want that taken care of. I'll play with Flex and PHP today (nothing better to do), see what I can make with that, and someone who knows SQL can modify the PHP to query the database instead of getting the averages from some fake files I'll create...

You got me interested in this, now I'm doing it... I hate that! :P (I'll probably have the whole thing except PHP's SQL queries done in a few days.... lol)