There are numerous things you can do with your respondents information. Let’s look at what developers need to know about integrating survey data.
Integrations
4 Ways SaaS Companies Can Integrate Survey Features into Existing Software
Integrations
Having all your applications in one place is helpful. Let’s look at five ways SaaS companies can integrate survey features into existing software.
10 Tips for White Labeling Success in 2021
Integrations
White labeling gives you our powerful software, branded for your business. In this article, we look at 10 tips for white labeling success in 2021.
Getting to your survey response data
Integrations, Product Information
Once you start a survey, it will collect responses for you. We collect your response data and then give it back to you several different ways. Here is a breakdown of the different ways you can collect the data from your responses.
Aggregate data in graphs
We collect your responses and show you the response data in aggregate in our reporting page. Using filters, you can also slice and dice your survey data, re-arranging your view of your data using answers to previous questions. So for example if you asked your respondents their gender, you could then filter you results just to see graphs of the responses from men or women.
View in PowerPoint
Many customers want to present their survey finding into PowerPoint presentations that they can then show to their collegues. We make this process easy with our feature to Export to Powerpoint by clicking the “Export to PPT” button at the top of the Reporting section of the survey.
View individual responses
If you are interested in seeing any particular response we give you a “grayed-out” view of individual responses. First look at your list of responses and then click the “View” icon.
Download Comma-separated values (CSV) file
If you want to manipulate your data in Excel or Google Sheets, you can export all your response data into a CSV and then from there you can import into different systems to create your own reports.
Receive via Webhook
Survey webhooks are notifications that we can send to a listener of your choice via an HTTP POST when someone takes certain actions in their survey account. A listener is simply a script that lives at a URL that stands ready to do something with the information we send it. Then when a respondent completes a survey we notify the listener with answers to the questions. That listener can then “do something” with the data immediately, like add it to a CRM database. Webhooks are the best way for programs to stay in sync with each other in real-time.
Retrieve via API
Unlike Webhooks which push information to you, our survey API allows you to retrieve you survey data “on-demand”. Get an API key from your account and connect to our service at https://api.surveytown.com/2/REST/ to retrieve your data in JSON format.
In sum, once your respondents start taking your survey, you can retrieve you data in a many ways. We strive to help you access your data in a way that is most useful to you at the time you want to get access to it.
Example code for PHP Webhook Endpoint
Integrations, Product Information
Every Webhook needs an endpoint — a listener script that “does something” when it receives a notification.
SurveyTown has survey webhooks that allow you to receive notifications when different events happen inside your SurveyTown account. Why would you want to receive these notifications? So a common use case would be if you wanted to update a separate systems when someone completed a survey, you could receive a webhook notification from SurveyTown when the survey was completed and after receiving that information you could then do something with that data such as update a CRM record, for example.
Webhooks themselves are an HTTP post notifications. To the non-technie, the notification itself just looks like a bunch of code. But buried in the code is all the details about the event. In the case of the RESPONSE_CHANGED webhook for example, the POST includes all the answers the respondent gave to the questions in the survey.
When setting up a webhook, you provide a URL where the information will be sent when the event happens – this is called the “endpoint” or the “listener”. But at that endpoint, there needs to be some code that “consumes” the information SurveyTown sends and does something with it. We thought it would be fun to give an example code that takes our RESPONSE CHANGED webhook and makes a CSV out of it responses. Why? Perhaps this CSV could then be downloaded into other business intelligence software for example. But turning the information into a CSV is just one example you could do. You could do a myriad of different things once you have the data.
So here is the example code, written in PHP that when notified by our RESPONSE_CHANGED webhook creates a CSV. It should be noted that you could modify this script to change the response data into any format you need – like XML or JSON. You could even skip saving to a file altogether and pass the data directly into a database or another process. But without further ado, here’s the code:
Example Webhook Endpoint Written in PHP that uses the “RESPONSE_CHANGED” webhook to create a CSV
<?php // Verify the webhook origin by checking for the Webhook Key value you defined in SurveyTown if( empty( $_REQUEST['key' ]) || $_REQUEST['key'] != "amazinglysecurekey" ){ http_response_code(200); die(); } // Look for the response_changed webhook event. Make sure the response is complete before processing. if( $_REQUEST['type'] == "response_changed" && ! empty( $_REQUEST['response'] ) && $_REQUEST['response']['isComplete'] == 1 ){ $columns = false; // Use a different CSV file for each survey $filename = "survey_responses_{$_REQUEST['survey_id']}.csv"; // Create the CSV header if the file doesn't exist if( ! file_exists( $filename ) ){ $columns = array( "ID", "IP Address", "Start Time", "End Time" ); } // Add response meta data $response = array( $_REQUEST['response']['responseId'], $_REQUEST['response']['ipAddress'], $_REQUEST['response']['responseStart'], $_REQUEST['response']['responseComplete'] ); // Loop through all the response data foreach( $_REQUEST['response'] as $key => $res ){ // Questions will have integer keys if( is_int( $key ) ){ // Handle multi value questions if( isset( $res['responses'] ) ){ foreach( $res['responses'] as $choice => $value ){ if( $columns ){ $columns[] = strip_tags( $res['questionText'] ) . " ({$value['choiceText']})"; } $response[] = $value['responseValue']; } // Handle single value questions }elseif( isset( $res['response'] ) ){ if( $columns ){ $columns[] = strip_tags( $res['questionText'] ); } $response[] = $res['response']['responseValue']; } } } // Open and write to the CSV $fp = fopen( $filename, "a" ); if( $columns ){ fputcsv( $fp, $columns ); } fputcsv( $fp, $response ); fclose( $fp ); } http_response_code(200);
Happy surveying!