IBH Insights

Updates, Insights, Coding Snippets and Marketing Musings

Getting Facebook Lead Ads Real-Time Data To An Endpoint For Integrating Into A CRM

by

After some development work on our end, we have successfully gotten the real-time Facebook lead ad updates to our endpoint using the PHP method the Facebook Dev Team goes over in this video walk through here. However the video is a little grainy at times so it can be hard to see the code, which we added below.

This walk through assumes some basic coding knowledge in PHP as well as the fact you know how to run the PHP files on a publicly accessible server so your callback will work. To make this integration with Facebook and your listener happen you’ll need three things.

1 – Correct Facebook App set up. I will assume you have a Facebook Developer account and know how to set up a basic app. Just make sure on webhook settings that you have a page subscription with the correct callback URL (the public URL you will place the PHP listener, which we will call webhook.php), and the fields are for ‘leadgen’ in the webhook settings. We had issues with the app accessing the listener unless it was on an https domain (so make sure you have a valid SSL cert), and you will also want to give the app domain permissions in any protective service like Cloud Flare or other firewall so Facebook’s payload won’t be blocked from hitting the listener.

facebook lead ads integration

2 – PHP listener at your callback URL. We can label this ‘leadhook.php’ or ‘webhook.php’ and call it from the Facebook app settings above. Here’s how we have ours set up for PHP:


3 – Some kind of platform page in your CRM to subscribe the pages. This is what we used below, it’s very basic but works as a good start point for a fuller app integration to your CRM:

Lead Gen Platform

Using the above we have successfully had our Facebook lead ads begin to hit our listener at the callback URL and thus allow us to handle the data in real-time from there. The above integration only sets it up to show the raw array from the lead event to hit your listener and get recorded to your error log so you can view it.

facebook lead ads to an endpoint

Use tail -f in terminal on your server to watch the event come in 'live' on the logs. Once you confirm it does, you can then use the $input variable to access the leadgen_id and from there use a GET request to Facebook via their API to pull the actual lead data the user filled out in the form. That part can wait for the next post though!

Leave a Reply

Conversion OptimizationIBH Company BlogWebsite Optimizations

How To Reduce Bounce Rate Over 90% With One Simple Fix

Admin Mar 17 2017
The Cost of Doing PPC Poorly
Business Marketing TipsIBH Company Blog

How Much Does PPC Cost If Done Poorly?

Admin Feb 3 2017
Why Use Search Engine Marketing
Business Marketing TipsIBH Company Blog

Why Use Search Engine Marketing Services When I Can Do It Myself?

Admin Feb 3 2017
Conversion Optimizations
Business Marketing TipsConversion OptimizationIBH Company BlogWebsite Optimizations

How Using Live Chat Got Us Over 220% More Leads

Admin Jan 11 2017
Inbound Horizons Inc.

Inbound Horizons Inc.

[contact-form-7 id="273" title="Short Form - Main"]

Please leave this field empty.

[contact-form-7 id="319" title="Rep Form - Main"]
I Am Interested In:



Please leave this field empty.