{# "Setup guide" popup of the Facebook & Instagram page. vars: redirect_uri, app_domain, webhook_url, verify_token, https, keys_saved, connected, got_lead #} {% macro copy(label, value) %} {% if label %}{{ label }}{% endif %} {{ value }} {% endmacro %} {% macro part(n, title, done=false, link=None, link_label='Open') %}
{% if done %}{{ icon('check', 'h-4 w-4') }}{% else %}{{ n }}{% endif %}

{{ title }}

{% if link %} {{ icon('external-link', 'h-3.5 w-3.5') }}{{ link_label }} {% endif %}
    {{ caller() }}
{% endmacro %} {% macro problem(title) %}
{{ title }}
{{ caller() }}
{% endmacro %} {% set b = 'font-medium text-gray-950 dark:text-white' %}

Before you start

{% if not https %}

{{ icon('circle-alert', 'h-5 w-5 shrink-0') }}This panel is open on http, not https. Meta will refuse it. Open the panel on its https address, or set app_url in your code.

{% endif %}

It takes about 15 minutes. Meta changes its screens now and then, so if a name differs a little, pick the closest one.

{% call part(1, 'Create a Meta app', keys_saved, 'https://developers.facebook.com/apps/creation/', 'Meta for Developers') %}
  • Sign in at developers.facebook.com. The first time, press Get started and confirm your phone and email.
  • Press Create app. Type a name (for example "My Business Leads") and your email, then Next.
  • Use case: pick Capture & manage ad leads with Marketing API, then Next.
  • Business: pick your business portfolio (or connect one later), then finish with Create app.
  • {% endcall %} {% call part(2, 'Add two permissions', connected) %}
  • In your app, open Use cases. Next to "Capture & manage ad leads with Marketing API" press Customize.
  • Find pages_manage_metadata and press Add. It lets the panel turn on new-lead alerts for your Pages.
  • Find public_profile and press Increase access (Meta asks for this before going live).
  • {% endcall %} {% call part(3, 'Copy the app keys', keys_saved) %}
  • Left menu: App settings, then Basic.
  • Copy the App ID. Next to App secret press Show (Facebook asks your password) and copy it.
  • Paste both in Meta app keys at the bottom of this page and press Save keys. The page reloads with Connect Facebook ready. Keep the secret private.
  • On the same Basic page, fill these and press Save changes. Meta needs them to publish the app: {{ copy('App domains', app_domain) }} Privacy Policy URL: a page on your website. User data deletion: a page that says how people can ask you to delete their data (your privacy page can say this). Also pick a Category and add an App icon (512 × 512).
  • {% endcall %} {% call part(4, 'Allow the login address', connected) %}
  • Left menu: Facebook Login for Business, then Settings.
  • Paste this in Valid OAuth Redirect URIs. It must match exactly: {{ copy(None, redirect_uri) }}
  • Keep Client OAuth login, Web OAuth login and Enforce HTTPS on, then press Save changes.
  • {% endcall %} {% call part(5, 'Publish the app', got_lead) %}
  • Left menu: Publish. Check the list, then press Go live.
  • Meta sends no leads to an app that is not live, not even test leads.
  • {% endcall %} {% call part(6, 'Connect Facebook', connected) %}
  • Close this guide and press Connect Facebook at the top of the page.
  • Continue as yourself. Choose every Page whose leads you want (or all current and future Pages), keep every permission on, and save.
  • You come back here. Your Pages show Receiving leads.
  • {% endcall %} {% call part(7, 'Send a test lead', got_lead, 'https://developers.facebook.com/tools/lead-ads-testing', 'Testing tool') %}
  • Open Meta's Lead Ads Testing Tool. Pick your Page and a form, then press Create lead.
  • In a few seconds the lead shows in Leads, and step 3 of Setup turns green. In the tool, Track status shows what Meta did.
  • A form can hold one test lead. Press Delete lead in the tool before making another.
  • {% endcall %}
    {{ icon('life-buoy', 'h-4 w-4') }}

    Common problems

    {% call problem("Facebook says \"Can't load URL\" or shows a redirect_uri error") %} The login address is missing or different. Paste it again in step 4, exactly as shown, and add the domain in step 3. {% endcall %} {% call problem('Facebook says "Invalid Scopes" or "This app needs at least one supported permission"') %} A permission is not added to the app. Do step 2 again, then press Connect Facebook. {% endcall %} {% call problem('No leads come in, not even test leads') %} The app is not live yet. Do step 5, then send a test lead again. {% endcall %} {% call problem('A Page is missing or shows "Not receiving"') %} Press Reconnect Facebook and tick every Page. You need full control of the Page, or task access with Advertise. {% endcall %} {% call problem('Nothing arrives at all') %} Someone may have limited Leads access. In Meta Business Suite open Settings, Integrations, Leads access, pick your Page, then on the CRMs tab press Assign CRMs and tick your app. On the People tab, make sure you are listed. Then press Sync forms and leads to fetch the leads you missed. If none of this helps, Meta may want App Review: in your app open App Review, then Permissions and features, and ask for Advanced access to leads_retrieval. {% endcall %} {% call problem('This page shows a webhook error') %} Meta could not reach this site. It must be public https with a real certificate (Let's Encrypt is fine, self-signed is not). You can also set it by hand: in your app open Use cases, Customize, then Webhooks (older apps: Webhooks in the left menu). Pick Page, paste the two values below, press Verify and save, then subscribe to leadgen. {{ copy('Callback URL', webhook_url) }} {{ copy('Verify token', verify_token) }} {% endcall %} {% call problem('Instagram leads do not show') %} Instagram lead ads belong to the Facebook Page linked to the Instagram account. Connect that Page and they come in with the rest, marked "on Instagram". {% endcall %}