Closed bastianilso closed 1 year ago
We need to make a clear overview of what is possible in terms of data capturing.
- How can we capture data about people's mouse clicks?
- I think we can use the JS event : "mousedown/mouseup" that allow us to detect when the mouse button is pressed then released on an element.
- We can use also the event "Click" that is triggered after a mousedown event and following a mouseup on the same element, if the left mouse button was used.
- How can we capture data about mouse movement? For me we can use the event "mousemove", each movement of the mouse over an element triggers this event.
- Example of implementation: input onmousemove="this.value=event.clientX+':'+event.clientY" value="Mouse over me"
- What possible storage backends are possible (JSON, CSV, MYSQL..)? -it is possible to use flat files like json, csv, excel etc...
- but we can also use databases like SQL server, mysql, maria DB etc... or on the cloud like Azure database for example.
- It depends on how much data we will have and how we want it stored, for example a csv file is structured by commas and semicolons.
These are my first hypotheses, what do you think?
Thanks @bilal-62210 ! Now we will need two things:
Here is an explanation of the columns:
Here is the CSV file that I screenshotted above, by the way. 🙂 example.csv
Also, in case you discover a JS library which can already capture this data and save you time, let me know! Then we can evaluate whether it makes sense to use it, or it's better to develop this data capturing system "from scratch" so to speak.
I've put my example implementation of capturing data from javascript and save the data to CSV on the "example_implementation" succursale. You can find the js file in the folder "mouse". For my example, fields value like "SessionID","DeviceID" and "session_duration" are fictive as we are not on the real environment. This is a demo of the implementation: 2022-09-26 08-45-41.zip
Give me your feedback @bastianilso .
Hi @bilal-62210,
Nice progress, thanks for the video. I had a look at your code.
The resulting CSV file needs to encode a header so you have the names of the columns in row 1 of the CSV file. Maybe it is already possible to do this with the JSON2CSV()
function.
The timestamp is incorrectly formatted (should be yyyy-mm-dd hh:mm:ss.mmm
), most likely there is an equivalent in JS to String.format()
you can use to achieve this.
<button id="button" onmouseover="mouselog(event)" onmouseout="mouselog(event)" onclick="mouselog(event)">click me</button>
<div id="parent" onmouseover="mouselog(event)" onmouseout="mouselog(event)">parent
<div id="child">child</div>
</div>
<textarea id="text"></textarea>
<input type="button" onclick="text.value=''" value="Clear">
<input type="button" id="btn" onclick="btn()" value="download csv">
mouselog(event)
function. Now, imagine we have 50 HTML pages with 100 elements each. It would be a lot of work to encode these function calls everywhere. A more managable way might be if we could tie the data capture to a specific class. For example, could we code the script such that if we add the CSS class logData
to an element, the element will have its interactions logged? For example <button id="button" class="logData">
. Just curious if it is possible.button
in the whole HTML page.$('button').bind('mouseover mousemove', function(e) { mouselog(event); });
@bastianilso
I've put the new example implementation of data capture javascript to csv file. With Csv header label added, new date format and mouselog(event) not called on every element only on the body of the page. This is on the "new version of the example implementation" commit. Take a look and give me your feedback. A demo of the new version: 2022-09-26 11-43-43.zip
@bilal-62210 Thanks. Please tell me a bit more - why did you settle for this technical solution, instead of the solutions I proposed in my previous reply?
Some comments:
yyyy/mm/dd hh:mm:ss.mmm
rather than yyyy-mm-dd hh:mm:ss.mmm
.
DeviceID
, I suggest we try to look into how to capture a hardware mac address from Javascript. I'm pretty sure there is API to do this or something similar from the browser.@bastianilso I am currently looking for the deviceID and I would like to ask you if you have any leads for research because all my research leads to this :
@bilal-62210 makes sense, have a look here - there is a description of an alternative solution + an NPM package. https://stackoverflow.com/questions/49692073/how-can-i-get-a-unique-device-id-in-javascript
@bastianilso I found a solution: i've implemente this function: wich create an ID that will be unique for browser/machine combo. the result of this function is : Do you think it can be a good solution?
@bilal-62210 sure, it might be a good solution, the function output looks good. But it depends on what is the ID based on and if it really is unique across sessions?
@bastianilso yes i think is unique across sessions because i've test it on chrome navigation and on private navigation and the ID changed.
@bilal-62210 what is the ID based on? how is it generated? why is the function called crypto.randomUUID
? what does the "random" part mean?
@bastianilso The ID is based on the UUID format, the function generate a random UUID and this random UUID become the machine ID. The machine ID will be unique for the browser/machine combo. Tell me if it's clear or not.
@bilal-62210 the device ID should be unique for the device. Which means, it cannot be random. We can use other measurements to determine if the device is the same, for example user agent, IP address,.. See the answer in the stackexchange thread I linked above.
@bilal-62210 ah, I understand now what you are saying it does.. OK so on the first run, the machine ID is generated and on subsequent runs, it is loaded from local storage. Sorry, this was not clear to me from your answers..this is fine then - the most important thing is, that the device ID keeps showing up if we run the test multiple times on the same machine. This is the test you can do, to make sure it works.
@bastianilso This is a demo : 2022-09-26 14-37-07.zip You can see that on the first run the machine ID is generate and after is loaded from local storage as you said above. You can also see that the machine id change when i run the code on private navigator but it keep the machine ID for next session. So i think it can work
We need to make a clear overview of what is possible in terms of data capturing.