Why use Webhooks?
You can alert third-party web apps about incoming leads. The new lead's data can be sent to a URL specified in the quiz settings. You would need to recieve this data on your side with a script and send it to a service of your choice. This method would be a perfect solution for integration with your CRM system or services that we do not provide directly supported integration yet.
A POST request will be sent to the specified URL. You can test lead reception at Webhook site
Important notice! The hook's srcipt must return a positive status while recieving leads (i.e. 20* - 200, 204, etc.)
In order to add the webhook reception address to your quiz, go to your quiz editor's Integrations and click the Webhooks button
In the appeared menu insert the link leading to your webhook script and don't forget to save the quiz by clicking the Save button
Lead data sent to the specified address will look something like this:
{ "raw": [ { "q": "ab6c5412-5c7f-489d-8d79-173ce632930e", "a": "3f0bb0ea-fc31-4b49-86b5-337ca0cf86da" }, { "q": "d337ecb3-b903-4664-94c1-16acf2c2e3bb", "a": "f3d4933b-6af3-48a9-a836-0173bbbf6415" } ], "answers": [ { "q": "What is your total sum of loans in USD?*", "a": "More than 100 000 USD." }, { "q": "What is your current loan delay?", "a": "1 to 3 months" } ], "contacts": { "name": "Name", "email": "email@email.com", "phone": "+12342345678" }, "quiz": { "id": "600920a2de60d9004900edb9", "name": "Gift generator🌟" }, "created": "2018-12-19T10:23:25.796Z", "extra": { "href": "http://example.com", "utm": { "source": "test_source", "medium": "test_medium", "name": "test_campaign", // Campaign "content": "test_content", "term": "test_term" }, "cookies": { "roistat_visit": "95852", "roistat_marker": "example.com", "roistat_marker_old": "example.com", "roistat_call_tracking": "1", "roistat_emailtracking_email": "null", "_ga": "GA1.3.2016698540.1531763909" }, "discount": 3, "discountType": "melting", "discountCurrency": "$", "currency": "USD", "currencySymbol": "$", "notify": "now", "ab": "A", (if A/B testing is enabled) "timezone": 5, "lang": "en", "referrer": "http://example.com" "ip": "111.11.111.111" } "result": { "id": "OBq5B3FYI6", "title": "Result header", "cost": "1500", "minCost": null, "maxCost": null } }
PHP code for new lead data reception:
$data = json_decode(file_get_contents('php://input'), true); $answers = $data['answers']; $phone = $data['contacts']['phone']; $email = $data['contacts']['email']; $name = $data['contacts']['name']; $createdDate = strtotime($data['created']); $utm = $data['extra']['utm']; $rawAnswers = $data['raw']; // Do anything http_response_code(200); exit;
Code template for separate reception of questions and answers data:
$i = 0; $arr = array(); foreach($answers as $key=>$value){ $arr[$i][$key] = $value; $i++; } //-------------First QUESTION------------------------ // $question1 = $arr[0][0]["q"]; // Question â„–1 $answer1 = $arr[0][0]["a"]; // Answer â„–1 //-------------Second QUESTION------------------------ // $question2 = $arr[1][1]["q"]; // Question â„–2 $answer2 = $arr[1][1]["a"];Â // Answer â„–2 //-------------Third QUESION------------------------ // $question3 = $arr[2][2]["q"]; // Question â„–3 $answer3 = $arr[2][2]["a"]; // Answer â„–3