How to Use ProProfs API to Capture Survey Takers’ Data for a Database/Website
Using our API, you can capture survey data on your website or web-server with ease.
Example Use Cases of Capture API
-
Inserting lead capture into your own database, such as name, email, etc., of survey taker
-
Inserting names and information for people that take the test into SugarCRM, SalesForce, or any other CRM system
-
Triggering emails or any other process on your website when someone takes the survey
This feature requires minor programming at your end to accept the data sent by ProProfs.
How it works
Whenever someone takes your survey, your notification URL will be called, which will accept the data. After accepting the data, you can write any custom code such as inserting into your database or CRM or triggering some business logic process.
How to Set Up the Callback URL
Go to the Settings page. Enable "Notification via API." Type the callback URL indicating where the script is on your site.
You can get JSON data by using the POST request. The sample code below shows how data can be retrieved. The POST request is enough to retrieve the data in the JSON method.
Content-Type : application/json
//This code will retrieve the data
$post_json = file_get_contents("php://input");
$post_json = json_decode($post_json,true);
$attempt_id = $post_json['attempt_id’'];
{
"survey_id":"149074",
"attempt_id":12345, // ex. $attempt_id
"attempt_date":"Sep-30-2019 1:57pm",
"survey_title":"API Notification",
"user_id":"12345", //custom_id
"email":"test@example.com",
"name":"John Smith",
"user_Score":"100",//if survey is scored
"question_answer":[
{
"question":"What shape is the moon?",
"answer":{
"answer_option":"Round",
"comment":""
},
"type":"Multiple Choice",
"score":"5", //if survey is scored
"question_id":"1"
},
{
"question":"What are the characteristics of the moon?",
"answer":[
{
"answer_option":"White",
"comment":""
},
{
"answer_option":"Round",
"comment":""
},
{
"answer_option":"Other (Please specify)",
"comment":"Big"
}
],
"type":"Checkbox",
"score":"5", //if survey is scored
"question_id":"2
},
{
"question":"Please, select the 2nd highest number.",
"answer":{
"answer_option":"5",
"comment":""
},
"type":"Choose from List",
"score":"5", //if survey is scored
"question_id":"3
},
{
"question":"Do you have any feedback for us?",
"answer":"Yes, we have",
"type":"Single Textbox",
"question_id":"4
},
{
"question":"What is your name?",
"answer":"John Smith",
"type":"Name",
"question_id":"5
},
{
"question":"What is your email?",
"answer":"john@example.com",
"type":"Email",
"question_id":"6
},
{
"question": "How likely are you to recommend this company to a friend or colleague?",
"answer":{
"answer_option":"10",
"comment":""
},
"type":"NPS Scale",
"question_id":"7
},
{
"question":"Rate the following",
"answer":"5",
"type":"Rating Scale",
"score":"5", //if survey is scored
"question_id":"8
},
{
"question":"Did you find what you needed?",
"answer":"Yes",
"type":"Button",
"question_id":"9
},
{
"question":"Please describe the moon.",
"answer":"Its big and white in color.",
"type":"Essay",
"question_id":"10
},
{
"question": "What are your favorite sports? Please rank your preferences below",
"answer":[
{
"answer_option":"Football",
"rank":"1"
},
{
"answer_option":"Cricket",
"rank":"2"
},
{
"answer_option":"Golf",
"rank":"3"
}
],
"type":"Ranking",
"question_id":"11
},
{
"question": "How much did you like the conference?",
"answer":[
{
"row_value":"The Topic",
"column_value":[
"I loved it"
]
},
{
"row_value":"The Premises",
"column_value":[
"I loved it"
]
},
{
"row_value":"The Speaker ",
"column_value":[
"I loved it"
]
}
],
"type":"Grid of Choices",
"question_id":"12
},
{
"question":"Your date of birth?",
"answer":"Jan-01-2010 1:00:am",
"type":"Date",
"question_id":"13
},
{
"question":"Please describe any two properties of the moon.",
"answer":[
{
"answer_option":"White"
},
{
"answer_option":"Big
}
],
"type":"Multiple Textbox",
"question_id":"14
},
{
"question":"Please draw your name",
"answer":{
"Date":"30-Sep-xxxx",
"Place":"",
"Name":"",
"Email":"",
"Job_Title":"",
"Company":"",
"Draw":""
},
"type":"Draw",
"question_id":"15
},
{
"question":"What is your address?",
"answer":{
"Address_1":"123, Block 2",
"Address_2":"",
"City":"Santa Monica",
"State":"California",
"Zip":"xxxxx",
"Country":"United States"
},
"type":"Address",
"question_id":"16
},
{
"question":"What is your phone number?",
"answer":"123456789",
"type":"Phone",
"question_id":"17
}
]
}