Skip to content
Menu

Setup guide

Running a jsPsych experiment on Tavra

Host your experiment where you host it now. Read the assignment reference from the URL, save data to your own server and redirect to Tavra's return link at the end.

Last updated November 14, 2026

How it fits together

Tavra opens your experiment's link with the worker's assignment reference added as a URL parameter. Your code reads it, stores it with the data and, when the timeline finishes, sends the browser to the return link from Tavra's template.

Set up your experiment

  • Save data to your own server before redirecting; jsPsych's local save is meant for testing, not online collection.
  • Keep the reference with every row so you can match data to approvals.
const params = new URLSearchParams(window.location.search);
const reference = params.get("REFERENCE_PARAMETER_FROM_TEMPLATE");

const jsPsych = initJsPsych({
  on_finish: async () => {
    await saveToYourServer(jsPsych.data.get().json(), reference);
    window.location.href = RETURN_LINK_FROM_TEMPLATE + encodeURIComponent(reference);
  },
});
jsPsych.data.addProperties({ tavra_reference: reference });

Sources

  1. jsPsych documentation, Running experiments on Prolific. Redirecting to a completion URL from on_finish with window.location. Checked November 14, 2026.
  2. jsPsych documentation, Data storage, aggregation and manipulation. Saving data to your own server; localSave is not recommended for online collection. Checked November 14, 2026.