- Personal Background + Work
- Collecting Information
- Pioneering Work
- Hands-on Example: Mouse Tracker
- AJAX
October 2nd 2014
KOF Swiss Economic Institute
Personal
Summary
Client Side Paradata
Server Side Paradata
Scripting languages
- Python - PHP - ASP - .NET - JSP - ...
Web servers
- Apache - Apache Tomcat - nginx - NodeJS - ...
Reips, U.-D., & Stieger, S. (2004). Scientific LogAnalyzer: A Web-based tool for analyses of server log files in psychological research. Behavior Research Methods, Instruments, & Computers, 36, 304-311
Stieger, S., & Reips, U.-D. (2010). What are participants doing while filling in an online questionnaire: A paradata collection tool and an empirical study. Computers in Human Behavior,
=> The web is moving fast: Frameworks have changed implementations substantially, but ideas and findings still very inspiring!
An R Example
# UAT Tool Example output rec <- "lXNtoilre7_2|M677|13|1320|M160|101|1750" split1 <- unlist(strsplit(rec,"M")) user <- split1[1] # should replace | with "" here (gsub) user
## [1] "lXNtoilre7_2|"
moves <- strsplit(split1[-1],"\\|")
moves <- lapply(moves,as.numeric)
l <- lapply(moves,'names<-',c("X","Y","time"))
do.call("rbind",l)
## X Y time ## [1,] 677 13 1320 ## [2,] 160 101 1750
Mouse Tracker that records mouse movement and reports coordinates in a standardized output format.
<!-- HTML: presentation, CSS: prettify, JS: Interaction --> <html> <head> <!-- Include CSS style sheets here --> </head> <body> <!-- Place some content here. --> </body> <script src="http://code.jquery.com/jquery-1.10.2.js"></script> <script> /* Place tracking scripts at the end to make sure everything is loaded. */ </script> </html>
jQuery is a fast, small, and feature-rich JavaScript library. It makes things like HTML document traversal and manipulation, event handling, animation, and Ajax much simpler with an easy-to-use API that works across a multitude of browsers. With a combination of versatility and extensibility, jQuery has changed the way that millions of people write JavaScript.
– jQuery.com, What is jQuery?
$(".jumbotron").mousemove(function(e) {
coordX = e.pageX;
coordY = e.pageY;
$("#coords").text("X: " + coordX + ", Y: " + coordY);
recordCoords();
});
JSON Example
[{"X":495,"Y":349},{"X":501,"Y":344},{"X":505,"Y":341}]
library(rjson)
json_list <- rjson::fromJSON(file = "application/coords.json")
coord_df <- data.frame(X = unlist(lapply(json_list,"[[","X")),
Y = unlist(lapply(json_list,"[[","Y"))
)
head(coord_df)
## X Y ## 1 340 464 ## 2 338 460
Note: In a real world setup the JSON string has to be send to the webserver!
$( "#send2server" ).click(function() {
$.ajax({
type: "POST",
url: "test.py",
data: JSON.stringify($dict)
});
});