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