How to Capture Learner Data and Send It to Your Database

 

You can easily capture course taker's data on your website using our API. 

 

Example Use Cases of Capture API

  • Obtain 'leads' into your database, information such as name, email, etc., of course takers.
  • Acquire 'contacts' of people taking your course in Salesforce or any other CRM system.
  • When someone takes the course, trigger emails or any other process on your website.

 

How it Works

This feature requires minor programming effort on your side to accept the data sent by ProProfs. Please note that this API is supported only in some of our high-end premium packages, such as those for businesses and enterprises.

 

To get started, you would need to make a file (your callback script) that will accept the data sent by the course through the 'REQUEST' method. It will call your callback script to accept the data whenever someone takes your course. After receiving the data, you can write any custom code required to insert the data into your database or CRM or trigger some business logic process.
  

Please follow the step mentioned below to set up the callback URL:

 

  • Open a course setting and switch to the Notifications tab. Scroll down to locate "Notification via API" and click to enable "Send lead capture & course attempt data to my website via API."  
  • In the field below, type the callback URL indicating where the script is on your site and click Save. The URL of the script will accept the data in the REQUEST method.

 

The below screenshot is an example used to depict the live scenario. In this example, we use a PHP path as the callback URL indicating the server location of data storage. Users have to use the callback URL in their script for the server location of data storage. 

 

Enable Notifications via API

 

There are a total of 15 attributes that we support and pass them to REQUEST when someone takes your course. It is similar to REST or SOAP API's.  
 
You would use the REQUEST array method to capture the course attempt information. ProProfs Training Maker will call your callback URL and post these variables to that particular script.
 
Here are the 15-course attributes(variables):
 
Use the REQUEST Array Method to Capture the Course Attempt Information
 
An Example: PHP and MySQL
Using PHP as server scripting, you can use the following example to test this feature.
 
Step 1: SQL
  • Create a table with the following SQL query:
 
<?php
	
	CREATE TABLE `course_takers` (
	`test_id` int(11) NOT NULL auto_increment,
	`report_id` int(100) NOT NULL,
	`course_id` int(100) NOT NULL,
	`name` varchar(150) NOT NULL,
	`email` varchar(150) NOT NULL,
	`id` varchar(150) NOT NULL,
	`phone` varchar(150) NOT NULL,
	`address` varchar(150) NOT NULL,
	`city` varchar(150) NOT NULL,
	`state` varchar(150) NOT NULL,
	`pincode` int(100) NOT NULL,
	`country` varchar(150) NOT NULL,
	`ip` varchar(150) NOT NULL,
	`time_taken` varchar(150) NOT NULL,
	`completed` int(100) NOT NULL,
	`attempt_date` timestamp NOT NULL,
	PRIMARY KEY  (`test_id`)
	)
	
	?>
 
 
Step 2: PHP
 

<?php
    /*--------------------------------------------------------------------------
    This is a basic example of the feature:
    "Allow capturing course taker's data for inserting in my own database/website"
 

   More Info & Help: https://help.proprofstraining.com/how-does-the-api-allow-me-to-capture-learners-data-and-insert-it-in-my-own-databasewebsite

   Contact Us: https://www.proprofs.com/contact/


   ProProfs.com
    ---------------------------------------------------------------------------*/
        //Do all database configuration here per your web server configurations
        $link = mysql_connect('localhost', 'mysql_user', 'mysql_password');
        if (!$link)
        {
        die('Could not connect: ' . mysql_error());
        }

 

        // Decide whether this is new attempt information or update request after assigning bonus points

 

   $check_prior_attempt = "SELECT * FROM course_takers WHERE report_id = '".$_REQUEST['report_id']."' LIMIT 1";
   $attempt_result = mysql_query($check_prior_attempt, $link);
   $attempt_status = mysql_num_rows($attempt_result);

 

        if($attempt_status == 0)
       {

                  // Means this is new attempt record for inserting into database
                      $report_id = $_REQUEST['report_id'];
                      $course_id = $_REQUEST['course_id'];
                      $name = $_REQUEST['name'];
                      $email = $_REQUEST['email'];
                      $id = $_REQUEST['id'];
                      $phone = $_REQUEST['phone'];
                      $address = $_REQUEST['address'];
                      $city = $_REQUEST['city'];
                      $state = $_REQUEST['state'];
                      $pincode = $_REQUEST['pincode'];
                      $country = $_REQUEST['country'];
                      $ip = $_REQUEST['ip'];
                      $time_taken = $_REQUEST['time_taken'];
                      $completed = $_REQUEST['completed'];
                      $attempt_date= $_REQUEST['attempt_date'];

 

      $sql_query = "INSERT INTO course_takers (report_id, course_id, name, email, id, phone, address, city, state, pincode, country, ip, time_taken, completed, attempt_date) VALUES ($report_id, $course_id, '$name', '$email', '$id', '$phone', '$address', '$city', '$state', $pincode, '$country', '$ip', '$time_taken', '$completed', '$attempt_date')";
    } else {

       

                // Means bonus points has been assigned and this is update request to update already stored attempt record.
               $sql_query = "UPDATE course_takers SET
               completed='".$_REQUEST['completed']."' ,
               time_taken='".$_REQUEST['time_taken']."'
               WHERE report_id='".$_REQUEST['report_id']."'
               LIMIT 1";
    }
   

              //Run query
              $query_run = mysql_query($sql_query, $link);                    

            //Rest of the code here...(per your needs)

?>

 

 

Troubleshooting Guide:

If you are having trouble making the API work, try the following troubleshooting steps:

  1. ProProfs originates all requests from public-facing IP '67.228.18.170'. Ensure that this IP is not blocked. 
  2. After unblocking the IP, check if you receive requests from our server. You can execute the snippet titled 'course_response_test.php' on your server. Change the email address in this script to your email ID. Then, update the callback URL of the course under "Edit Settings" -> "Notifications" to call this URL. Check if you receive an email after you complete the course. It validates if responses from ProProfs reach your server.

 

Click here to download the PHP script (course_response_test.php)

 

Feel free to contact us if you need further assistance.

 

 

© 2005 - 2024 ProProfs
-
add chat to your website