Redirecting from Qualtrics to PCIbex and then back to SONA

PennController for IBEX Forums Support Redirecting from Qualtrics to PCIbex and then back to SONA

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #5741
    mrhelfrich
    Participant

    Hello, this question might be a little bit outside of the scope of these forums but I think it should be relatively easy to solve.

    Right now, my PCIbex-based experiment is the 2nd and final task I want participants to complete, after first completing a survey hosted via Qualtrics. Participants sign up for the overall experiment via SONA and when using only Qualtrics a means of having Qualtrics generate a unique ID for each participant that gets sent back to SONA to confirm completion is used. I have almost no understanding of this process but it seems to just add information to the end of the links being used, so the link to Qualtrics given to participants in SONA just needs to add ?id=%SURVEY_CODE% to the end and the Qualtrics study needs an embedded data field called “id” added to it. Upon completing the Qualtrics survey, redirecting back to SONA with “?experiment_id=XXX&credit_token=YYY&survey_code=${e://Field/id}” added to the link is all that is needed to return back to SONA and if the id values match then credit is granted.

    I know that PCIbex allows for SONA integration (got my information from this thread). I tried following that thread, but put the Qualtrics survey as the outgoing link from SONA, had the Qualtrics survey redirect to PCIbex, and then, as described in the thread, put my return link to SONA at the end of the PCIbex task. This works in terms of routing but the final step fails as I don’t think the id that gets sent from Qualtrics to PCIbex is handled properly, so when PCIbex redirects back to SONA, the incoming id is not the same as what SONA is expecting.

    I think it is possible to make this work by having Qualtrics’ id value be read in by PCIbex and then get sent back to SONA, whereas my code right now in PCIbex creates a unique ID and doesn’t read in what Qualtrics sends so the survey code received by SONA is always going to be wrong.

    I think the relevant bits of my code (and redirect URLs) to change are:

    Redirect link in Qualtrics that sends the participant to PCIbex:
    “…expt.pcibex.net/ibexexps/[MYNAME]/[MYEXPERIMENT]/experiment.html”
    – I think this needs some way of reading in the id value created in Qualtrics, possibly referred to as “&survey_code=${e://Field/id}”

    PCIbex code that establishes an id (based on the linked thread)

    Header(  
        newVar("id").global(),
    )
    .log("ParticipantID",getVar("id"), PennController.GetURLParameter("id") )

    – Appears at the top of my script and probably needs to read-in the value sent by Qualtrics and not create a new value

    PCIbex code that appears at the very end of my script (the last trial in the sequence)

    newTrial("endexp",
        newText("<p>Your results have been saved, but you need to validate your participation below. This is a necessary step to grant you credits!</p>").print(),
        newText("<p><a href='https://[SONASITE].com/webstudy_credit.aspx?experiment_id=XXX&credit_token=YYY&survey_code=${e://Field/id}"+PennController.GetURLParameter("id")+"'>Click here to confirm my submission on SONA</a>.</p>").print(),
        newButton("void").wait()
    )

    – I think that the link included here cannot be changed, so we need PCIbex to have this format and make sure that the survey_code is the same as the id in Qualtrics

    One other consideration is that SONA itself creates the id value, sends it to Qualtrics and expects it back. I don’t think this would change the solution however.

    Any help you can provide would be greatly appreciated and thank you for such a useful tool.
    Max

    #5742
    Jeremy
    Keymaster

    Hi Max,

    Follow the instructions on this page but at step 3, from the screenshot, replace
    YOURSCHOOL.sona-systems.com/webstudy_credit.aspx?experiment_id=XXX&credit_token=YYY&survey_code=${e://Field/id}
    with
    expt.pcibex.net/ibexexps/[MYNAME]/[MYEXPERIMENT]/experiment.html?survey_code=${e://Field/id}

    Then, simply edit you last trial so it looks like this:

    newTrial("endexp",
        newText("Your results have been saved, but you need to validate your participation below. This is a necessary step to grant you credits!").print(),
        newText("<a href='https://YOURSCHOOL.sona-systems.com/webstudy_credit.aspx?experiment_id=XXX&credit_token=YYY&survey_code="+GetURLParameter("survey_code")+"'>Click here to confirm my submission on SONA</a>.").print(),
        newButton("void").wait()
    )

    You should probably also edit your header like this:

    Header(
      // void
    )
    .log( "ParticipantID" , GetURLParameter("survey_code") )

    Let me know if this works

    Jeremy

    #5743
    mrhelfrich
    Participant

    It appears to have worked, I cannot be certain until the experiment actually launches since I cannot complete it as a dummy participant but I get same result when testing the integration with Qualtrics only so it appears to be receiving the correct survey code.

    Thank you very much for your help!

    #5750
    samsanto
    Participant

    Hi Jermey,

    I’m jumping in here because I am trying to do something very similar and cannot figure it out. I want add a Qualtrics link in my study, however instead of using “PennController.GetURLParameter(“id”)”, I randomly generate a participant ID as a global variable and want to use that in my link. I’ve tried many, many ways to integrate my variable into the outgoing link and it either does not form a clickable link, or the link is clickable, but instead of the participant ID # actually being integrated, it just says “[object%20Object]” (type cast error??).

    Here is my code with two of the ways I have tried to integrate the PID, if you could help me out, I’d appreciate it!

    
    PennController("genID",
        newVar("subjID")
            .global()
            .set(Math.floor((Math.random() * 10000) + 1))
    )
    .log( "id" , getVar("subjID"));
    
    PennController( "testLink" ,
        
            //I tried just "getVar("subjID") also but thought maybe it needed to be in text ("string") form but neither seem to work for me
            newText("ID", "").text(getVar("subjID"))
            ,
            
            //Attempt #1 (not a clickable link)
            newText('<a href="https://umdsurvey.umd.edu/jfe/form/SV_a9pG7czZy4cfAPP?ID=')
                .after( newText().text(getVar("subjID")))
                .after( newText('">Click here to go the next part of my study</a>'))
                .print()
            ,
            
            //Attempt #2 (link doesn't have the actual PID in the URL, just [object...]
            newText("<p><a href='https://umdsurvey.umd.edu/jfe/form/SV_a9pG7czZy4cfAPP?ID="+getText("ID")+"'>Click here to go the next part of my study</a>.</p>")
            .print()
            ,
            
            newButton("Continue")
                .print()
                .wait()
    
    );
    

    Thanks for any suggestions,
    Sam

    #5752
    Jeremy
    Keymaster

    Hi Sam,

    The get* commands represent PennController elements: as such, they can be parameters of other PennController commands, but you cannot simply use them in a plain string like this. What you can do is use the set command of the Var element, which lets you manipulate its value in plain javascript:

    newTrial("genID",
        newVar("subjID")
            .global()
            .set(Math.floor((Math.random() * 10000) + 1))
    )
    .log( "id" , getVar("subjID"))
    
    
    newTrial( "testLink" ,
        newVar("link")
            .set( getVar("subjID") ) // Fetch ID first, then insert it into the link
            .set( v => "<p><a href='https://umdsurvey.umd.edu/jfe/form/SV_a9pG7czZy4cfAPP?ID="+v+"'>Click here to go the next part of my study</a></p>." )
        ,
        newText()
            .text( getVar("link") ) 
            .print()
        ,
        newButton("Continue")
            .print()
            .wait()
    )

    Jeremy

    #5784
    samsanto
    Participant

    Ah! That totally makes sense. Thanks so much Jeremy! This works great.

Viewing 6 posts - 1 through 6 (of 6 total)
  • You must be logged in to reply to this topic.