***THIS ARTICLE IS INTENDED FOR TECHNICAL USE AND CONTAINS TERMS THAT MAY NOT BE SUITABLE FOR NON TECHY LAYMEN ;) FOR THE REST OF US, HERE IS AN ARTICLE THAT BREAKS IT DOWN IN A SLIGHTLY MORE DIGESTIBLE FORMAT***
First, set up your Nugget to send lead data to your webhook:
- Create a new Nugget as you normally would (here's a video to remind you how easy that is). Or, you may choose to edit an existing Nugget.
- Once you've finished designing your Nugget, click Next. The next step in the flow will ask you where you want to send leads captured by this Nugget.
- From the ADD INTEGRATION drop down menu, select Webhook. Enter the Webhook URL in the input field.
When you enter a URL in the "Webhooks" field, we'll hit this URL with POST requests when you get a conversion on the Nugget, passing along information about the conversion.
New JSON format:
{
"campaign": {
"id": 7,
"title": "Campaign with webhook"
},
"nugget": {
"id": 13,
"title": "Nugget with webhook"
},
"fields": {
"name": "test",
"email": "test@email.com"
},
"conversion": {
"url": "http://mysite.com/test",
"page_title": "Test page"
},
"ip": "123.456.78.90"
}
Here is some sample code (in PHP) you can use on your side, for the webhook target URL:
<?php function doSomething($nuggetTitle, $campaignTitle, $name, $phone, $email, $company, $customField, $conversionUrl, $conversionPageTitle) { //here you can do whatever you want with the data you get from //the conversion for example add to SalesForce, add to a mailing list, //follow them on Twitter... } if ($_SERVER['REQUEST_METHOD'] == 'POST') { $postdata = file_get_contents("php://input"); $conversion_details = json_decode($postdata, true); $nuggetTitle = $conversion_details['nugget']['title']; $campaignTitle = $conversion_details['campaign']['title']; $fields = $conversion_details['fields']; $name = isset ($fields['name']) ? $fields['name'] : null; $phone = isset ($fields['phone']) ? $fields['phone'] : null; $email = isset ($fields['email']) ? $fields['email'] : null; $company = isset ($fields['company']) ? $fields['company'] : null; //Replace this with whatever custom fields you have in your nugget $custom = isset($fields['customField']) ? $fields['customField'] : null; $conversionUrl = $conversion_details['conversion']['url']; $conversionPageTitle = $conversion_details['conversion']['page_title']; doSomething($nuggetTitle, $campaignTitle, $name, $phone, $email, $company, $customField, $conversionUrl, $conversionPageTitle); } ?>