jsPsych
Participants arrive at your experiment's address with three IDs added: PARTICIPANT_ID (pseudonymous, different for each lab), STUDY_ID, and SESSION_ID (one per attempt). This works with jsPsych 7 and 8.
-
1. Save the IDs with your data
Right after you create jsPsych, add the IDs to every trial's data:
jsPsych.data.addProperties({ PARTICIPANT_ID: jsPsych.data.getURLVariable("PARTICIPANT_ID"), STUDY_ID: jsPsych.data.getURLVariable("STUDY_ID"), SESSION_ID: jsPsych.data.getURLVariable("SESSION_ID") }); -
2. Send participants back when they finish
Redirect to your study's completion address in on_finish. Copy the exact address from your study page (under “Connect your survey”); it looks like this:
Save your data before redirecting, for example with a save trial at the end of the timeline or in on_finish before the redirect.
For other endings (screen-outs, failed attention checks), redirect with a different completion code from your study page. Each code can approve, reject, screen out (paid), or add people to a group.
const jsPsych = initJsPsych({ on_finish: () => { window.location = "https://populiva.com/c/STUDY_ID?code=COMPLETION_CODE"; } }); -
3. Add the quality snippet (optional)
Paste this tag into the <head> of your experiment's HTML page. It reads SESSION_ID from the page address, so it needs no other setup. A jsPsych experiment is one page, so the snippet reports the whole experiment as one page.
The snippet sends only counts (time, tab switches, pastes, typing speed, automation), never responses. data-ai-check adds a hidden instruction that only AI agents read; delete that attribute if you don't want it.
<script src="https://populiva.com/q.js" data-ai-check="on" async></script> -
4. Tell participants
If you use the snippet, say so in your consent form, for example: “This experiment records counts of activity, such as time spent and pasting, to check data quality. It doesn't record your responses or what you type.”
Test before you launch
Open your survey link with test values added, for example ?PARTICIPANT_ID=test&STUDY_ID=1&SESSION_ID=test, and check that the three values are saved with your test response.
The snippet ignores sessions it doesn't know, so tests don't create data. The completion address will say there's no active study for you; that's expected outside a real session.