Getting Pavlovia to host a custom JavaScript/html experiment and save the data? Help!

URL of experiment:
https://run.pavlovia.org/pmmacabulos/driving-sim/

  • Currently users press A & D key to move car left and right.
  • Pressing space bar does nothing in-game, but the timestamp of when you hit space is saved to a CSV file.

Description of the problem:
i’m creating a driving simulator videogame from scratch using JavaScript/html for my PhD (I.e. not using builder). I want Pavlovia to host this experiment, and also save any data from it into a CSV file that I can access under the data tab.

I’ve been able to get Pavlovia to host the experiment using this helpful thread: Use Javascript task on Pavlovia

However I cannot figure out how to get Pavlovia to save any experiment data into a CSV file that I can store/access in my account.

For example, I want to create a csv file that stores the timestamp of every time a user presses the space bar in the experiment. So far, I can code this in JavaScript and i’ve created button that downloads a csv file of this data locally to your computer. But how would I get this csv file to be stored/accessed on my Pavlovia account instead? Kind of like how it automatically generates one for your PsychoPy experiments?

Any help would be sincerely appreciated! :pray:
I’d love to know what code I need to add to my experiment to translate it into something Pavlovia can work with.

Note:
I’m used to creating experiments with PsychoPy/builder and I’m a newbie coder in JavaScript/html. I kinda know that Pavlovia uses jsPsych to handle data saving, but I’m lost on the specifics of how this works :smiling_face_with_tear:

If you are a newbie coder in JavaScript, why aren’t you using Builder?

If you want to continue without Builder, I’d recommend that you create a very simple experiment in Builder and then have a look at the index.html and JavaScript files it creates to look for the essential commands you might need to save data.

N.B. Data files in PsychoJS are normally generated as the experiment ends, not while it is still going.

1 Like

W/r/t jsPsych, basically there’s a Pavlovia plugin that you can include in your code that saves the data to Pavlovia’s server. There’s some (somewhat outdated) information here: Pavlovia

For what you’re describing I think the basic solution is going to be to use jsPsych, see if you can fit your entire game inside an HTML response element (html-keyboard-response - jsPsych), have it save a bunch of custom fields with addProperties (jsPsych.data - jsPsych) and then let the pavlovia plugin do the actual saving at the end of the experiment.

1 Like

This is super useful, thank you!
And I appreciate the links :slight_smile:

I’ll be looking into jsPsych now and see if I can build the experiment that way. It shouldn’t be impossible.

Thanks for the heads up!

I’ll experiment with this.