External Study Credit Granting with jsPsych

While these instructions refer to “credit granting”, they work for both credit and paid studies. For paid studies, participation will be marked (instead of credit granted) just like with any other paid study.

Here are the basic steps, which are subject to change (since the product is controlled by jsPsych):

  1. On your Sona Systems site, change the Study URL so it includes ?sona_id=%SURVEY_CODE% in the URL. So if the jsPsych URL is:
    https://jspsych.yourschool.edu/mystudy
    then change it to
    https://jspsych.yourschool.edu/mystudy/?sona_id=%SURVEY_CODE%
  2. Having completed Step 1, the Study Information on your Sona Systems site now displays two URLs labeled “Completion URLs”. The URL to use would be similar to:
    https://yourschool.sona-systems.com/webstudy_credit.aspx?experiment_id=123&credit_token=4e48f9b638a&survey_code=XXX” and is the client-side URL. Copy the Completion URL (client-side) value from there. Remove the XXX value from the end of it. Save that URL for the next step.
  3. In jsPsych, go to the source code of the task for the experiment you wish to link to Sona. Add lines similar to the following block for both on_finish line and the line beginning with let sona_id. Use the Completion URL (client-side) from the Study Information Page in Sona. Add lines similar to the following on_finish line to your experiment (the URL you saved from the prior step with +sona_id after it as shown in example below) and the line defining sona_id at the top.
    let sona_id = jsPsych.data.urlVariables()['sona_id']
    jsPsych.init({
        timeline: [hello],
        on_finish: function(data){ 
            window.location.assign("https://yourschool.sona-systems.com/webstudy_credit.aspx?experiment_id=123&credit_token=4e48f9b638a&survey_code="+sona_id)
        },
    })
    

Thanks to this site for guidance with the integration.