1 · Pass the Samply IDs into the survey
The reserved r parameter is auto-stored in the built-in REF variable; other custom u_ parameters are captured with a "Device and Transmitted Variables" question on the first page.
- Send the message id as the reserved parameter r (e.g. ?r=%MESSAGE_ID%). SoSci automatically stores r in the built-in REF column — no setup needed.
- To also store the Samply ID and participant code, add a "Device and Transmitted Variables" question on the FIRST page and declare the custom variables to read (their names must start with u, e.g. u_sid, u_code).
- Those values are then written to the dataset and appear in the export.
- Run a test interview and confirm REF (and the u_ columns) hold the transmitted values.
2 · Register completion
A "PHP code" element placed alone on the final page calling redirect(url, false), which marks the interview FINISHED and redirects.
- Add a final questionnaire page containing ONLY a "PHP code" element (commands after redirect() are ignored).
- Build the redirect with SoSci's %reference% placeholder, which resolves to the stored REF value: redirect('https://samply.uni-konstanz.de/studies/<study-code>/done/%reference%', false);
- Keep the second argument false so SoSci marks the dataset complete before sending the participant to Samply.
- Test a full interview from a real Samply link and confirm it lands on /studies/<study-code>/done/<message-id>.
Or register completion silently with a POST
The redirect above navigates the participant's browser to Samply. The same completion can instead be registered server-to-server with an HTTP POST to /studies/<study-code>/done/<message-id> — no request body and no authentication (the message id in the path is the shared secret). Samply replies 200 on success or 400if the id matches no response, and it records the completion and cancels that send's pending reminders exactly like the redirect — just without redirecting. Whether SoSci Survey can issue that POST itself varies:
- Add a contentless page just before SoSci's final/goodbye page and place a "PHP code" element on it; an empty page auto-forwards after the PHP runs, so the real last page still sets FINISHED.
- Read the message id from the built-in REF variable with reference() — the value SoSci stored from ?r=%MESSAGE_ID% in the start link.
- Build the URL with the id in the path and POST with an empty body: $url = 'https://samply.uni-konstanz.de/studies/<study-code>/done/'.reference(); sendPOST($url, array());
- Do NOT call redirect() — sendPOST() returns inline and the participant continues to the last page. Optionally guard with if (strlen(reference()) == 15).
- Mind SoSci's outbound limits (~1000 requests/24h per project, 20 per interview, 2 per page; 5s timeout, no retry). A high-volume ESM study can hit the daily cap, where the redirect has none.
POST sources: https://www.soscisurvey.de/help/doku.php/en:create:functions:sendjson · https://www.soscisurvey.de/help/doku.php/en:create:functions:reference · https://www.soscisurvey.de/help/doku.php/en:create:lastpage
Full request and response details are in the API reference.
Reserved parameters & gotchas
r is reserved (auto-stored in REF) — that is exactly what we use for the message id, and %reference% reads it back. Custom parameter names must start with u (e.g. u_sid). readGET() only reads on the first page.
Things to watch out for
- If you instead capture the id into your own variable, inject it with PHP instead of %reference%, e.g. redirect('https://samply.uni-konstanz.de/studies/<study-code>/done/'.value('IV01'), false);
- No SoSci plan/tier restriction applies — redirect() and URL-parameter capture are standard features.
Sources
These steps were verified against the platform's official documentation.