In addition of providing a standard method for exporting the responses of a survey, QualtricsInR provides an useful method for efficiently handling the download of multiple surveys.

The process to retrieve survey data requires 3 steps: 1) request the data from Qualtrics, 2) wait while the data is being prepared, 3) download the data (more information can be found here). It may therefore be more efficient, when downloading responses from multiple surveys to 1) request the downloads 2) download the prepared files once they are ready.

Finding your Survey Id

You can always find the id of one of your surveys by logging into your Qualtrics account and inspecting the URL when previewing your survey or inspect your Qualtrics IDs account page. Through the API, it is however straightforward to list all the surveys available in your account:

# retrieve all available survey ids from your account
lst_surveys <- list_surveys()
print(lst_surveys)
#> # A tibble: 9 × 6
#>   id                 name       ownerId    lastModified   creationDate  isActive
#>   <chr>              <chr>      <chr>      <chr>          <chr>         <lgl>   
#> 1 SV_39rgGREdlmzH63X api_copy_… UR_1Z96ys… 2020-06-11T08… 2020-06-10T0… TRUE    
#> 2 SV_3fmfHkdddhnRbKJ api_copy_… UR_1Z96ys… 2020-06-11T08… 2020-06-11T0… FALSE   
#> 3 SV_6WpcSqtVBsibNcN api_copy_… UR_1Z96ys… 2020-06-11T08… 2020-06-11T0… FALSE   
#> 4 SV_9Ak7vCha9W42Twp api_copy_… UR_1Z96ys… 2020-06-11T08… 2020-06-11T0… FALSE   
#> 5 SV_aYwagyEbamVLpFX api_copy_… UR_1Z96ys… 2020-06-11T08… 2020-06-11T0… FALSE   
#> 6 SV_blW4HuzdeqLiTJ3 api_expor… UR_1Z96ys… 2020-04-16T18… 2020-04-16T1… TRUE    
#> 7 SV_cScDRSV5hsN3YEd api_distr… UR_1Z96ys… 2020-06-10T08… 2020-04-16T0… TRUE    
#> 8 SV_elpspu2EuJXLEWx api_expor… UR_1Z96ys… 2020-04-16T18… 2020-04-16T1… TRUE    
#> 9 SV_esXQqpyoyNFeW69 api_copy_… UR_1Z96ys… 2020-06-11T08… 2020-06-11T0… FALSE

Survey Response Status

Rather than exporting the full set of responses from a survey, you might only be interested in checking the current status of total responses:

get_survey_response_counts("SV_elpspu2EuJXLEWx")
#> $auditable
#> [1] 3
#> 
#> $generated
#> [1] 0
#> 
#> $deleted
#> [1] 0

The call returns a list with 3 elements corresponding to the valid survey responses (‘auditable’), the responses that were generated or deleted.

Standard Export Method

You can export the responses from your survey using the get_survey_responses() function. To retrieve the id of your survey, you can use the list_surveys function.

# export survey responses
get_survey_responses("SV_cScDRSV5hsN3YEd")
#> # A tibble: 3 × 19
#>   StartDate    EndDate     Status IPAddress  Progress `Duration (in se… Finished
#>   <chr>        <chr>       <chr>  <chr>      <chr>    <chr>             <chr>   
#> 1 2020-04-16 … 2020-04-16… 0      86.220.39… 100      5                 1       
#> 2 2020-04-16 … 2020-04-16… 0      86.220.39… 100      10                1       
#> 3 2020-04-16 … 2020-04-16… 0      86.220.39… 100      13                1       
#> # … with 12 more variables: RecordedDate <chr>, ResponseId <chr>,
#> #   RecipientLastName <chr>, RecipientFirstName <chr>, RecipientEmail <chr>,
#> #   ExternalReference <chr>, LocationLatitude <chr>, LocationLongitude <chr>,
#> #   DistributionChannel <chr>, UserLanguage <chr>, Q1 <chr>, Q2 <chr>

By default, the data is not saved on disk. You can save your data in a desired location by using the saveDir argument.

get_survey_responses("SV_cScDRSV5hsN3YEd", format = "csv", saveDir = "./data/", filename = "test_survey")

The default file format is json but csv and tsv can be passed. We currently don’t provide the SPSS file format as an output option. The file is automatically named with the survey id if the parameter filename is not specified.

A number of optional parameters can be passed to the function. Be aware that any download that exceeds 1.8 GB will need to be split in several exports using different time intervals (dates specifications follow the ISO 8601 standard YYYY-MM-DD (more information here). For example:

get_survey_responses(
  "SV_cScDRSV5hsN3YEd", 
  format = "csv", 
  startDate = "2020-04-01T07:31:43Z", 
  endDate = "2020-04-29T07:31:43Z")

Instead of exporting the recode value for the answer choices, you can export the text of the answer choice by setting the parameter useLabels to TRUE:

get_survey_responses(
  "SV_cScDRSV5hsN3YEd", 
  format = "csv", 
  useLabels = TRUE)

Retrieving Responses for Multiple Surveys

If you need to download responses from multiple surveys or you have a need to schedule regular automated exports of multiple survey responses, we recommend you use the approach documented below. Instead of looping over each survey, requesting the export and downloading the file from the Qualtrics server, we will send the request to Qualtrics to prepare all the files and then export them.

# request creation of response exports
requests <- request_downloads(lst_surveys$id, format = "csv")
requests
#> Download Requests:
#>  ✔ 9  Successful
#>  ✖ 0  Unsuccessful
# download the response files
data <- download_requested(requests)
length(data)
#> [1] 9
head(data[[1]])
#> # A tibble: 1 × 19
#>   StartDate     EndDate    Status IPAddress Progress `Duration (in sec… Finished
#>   <chr>         <chr>      <chr>  <chr>     <chr>    <chr>              <chr>   
#> 1 2020-06-10 1… 2020-06-1… 1      <NA>      100      2                  1       
#> # … with 12 more variables: RecordedDate <chr>, ResponseId <chr>,
#> #   RecipientLastName <chr>, RecipientFirstName <chr>, RecipientEmail <chr>,
#> #   ExternalReference <chr>, LocationLatitude <chr>, LocationLongitude <chr>,
#> #   DistributionChannel <chr>, UserLanguage <chr>, Q1 <chr>, Q2 <chr>

The download will return a list with each element containing the responses for each individual survey.

The implementation takes into account the rate limit imposed by Qualtrics for this specific call. Once the limit is attained in looping accross the different survey ids, the procedure waits a few seconds before trying again. You can set the parameter retryOnRateLimit to FALSE and the procedure will stop upon the first error returned by Qualtrics.