Send data from CRM to Facebook conversion API using webhooks - Stape

Send data from CRM to Facebook conversion API using webhooks

The Facebook conversion API is a powerful tool that allows you to track your website’s visitors and their activity on your site. This data can then be used to create custom audiences, test out different versions of ads, or even provide insights into who might be interested in the product.

The most popular way of integrating Facebook conversion API is using the Google Tag Manager server container. But there are other ways to do that: using Zapier, direct integration, integration with the CRM using webhooks, and much more. 

There are many Facebook conversion API integration methods, each with its pros and cons. You can check out our article explaining how to set up Facebook CAPI using a GTM server container. This blog post describes how you can send data from your CRM to Facebook conversion API using webhooks.

The benefits of integrating CRM with Facebook conversion API

How people interact with your business is a mystery that the FB pixel alone could never solve. Facebook pixel can help you understand the user journey better and attribute more conversions to Facebook ads for people interacting with your site.

Some companies may receive a decent number of offline orders or leads. For instance, purchases may be initiated online but completed in-store or through a call center. 

While a Facebook pixel sends online activity through the web browsers your customers use when they visit your website, the Conversions API integrated with the CRM lets you send activity directly from your CRM. That gives you more control over the type of activity you can measure both on and offline.



Most popular cases of using CRM webhooks to send data Facebook CAPI

One of the most popular use cases for integrating CRM with Facebook CAPI  is tracking purchases from phone calls. Some people may see your ad on Facebook, click on the ad, but then might have some questions about products or services. That is why they may decide to contact your business and make purchases over the phone. 

In this situation, Facebook had a significant impact on a user’s purchase decision. But it will never be attributed to any of your campaigns. Integrating CRM with Facebook will give you more information about what campaigns and ads drive conversions, including offline conversions. 

The second use case is when you want to track purchases confirmed by the client separately. In this case, you can send webhooks whenever the order status changes to confirmed. 

Another popular way of using webhooks is to track payments from PayPal or Stripe. If a purchase happened on PayPal or Stripe’s domain, you can’t access the user and product data, hence can’t send it to FB. The easiest way to track PayPal or Stripe transactions on FB is using webhooks. 

The tricky part with webhooks is using a browser+server model of tracking. If you want to send FB browser events for the same CRM webhooks, it may be hard to do since you’ll need to send the identical event IDs from the web and server to make deduplication work. If using the same event ID is impossible, it’s better to track CRM events only from the server to avoid event duplication.

How to send Webhooks from CRM to Facebook conversion API

    1. Set up a Google Tag  Manager server container. 
    2. Copy the tagging server URL in the stape.io admin console

stape.io tagging server url

 

3. Create a webhook. Paste this tagging URL in the Delivery URL of your webhook and add a path that will differentiate this particular webhook from the other webhook. 

In my case, its:

Tagging_url  https://ottpwgmj.eu.stape.io

Path: /order_created

create webhook in CRM

 

4. Open the preview mode of the GTM server container -> Click three dots at the top right corner -> Click Send requests manually -> Copy the X-Gtm-Server-Preview HTTP header.

gtm server preview header

 

5. Log in to your stape.io account -> Click Settings on the right side of the container -> Click Preview header config -> Paste the X-Gtm-Server-Preview HTTP header that you’ve copied in step #4. 

paste preview header stape.io

 

6. Test the webhook. You should see requests from the webhook in the GTM server preview mode.

test CRM webhook in the server container

 

7. In this step, we will set up a Client in the GTM server container that will listen to the requests sent by the webhook. First of all, download Data Client from GitHub -> Open Templates tag in the GTM server container -> Click new -> Import Data Client -> Click save and publish the server container. It is required to publish a data client the first time you add it. Otherwise, you’ll see a CORS error in the console. 

upload data client

8. Set up a Data Client. Open a Client tab -> Click New -> Select type Data Client -> Open More Settings -> Add the webhook path that you’ve added in the step 3 -> Save. 

set up data client to listen to all requests

 

9. Open the GTM server preview mode and test the webhook. Now you should see that Data Client claimed a webhook request. Click the Events Data tab, and you will see the webhook data. 

webhooks request claimed

webhook data in the GTM server container

 

10. Create variables that will extract data from the webhook to use for Facebook conversion API. Open the  Variables tab -> New variable -> Variable type Event Data -> Set up event variables for each variable you want to use to set up Facebook conversion API. 

webhook data to variable in gtm server container

 

11. Set up Facebook conversion API for the webhook that you’ve created. Create a new tag -> Tag the Facebook conversion API -> In the Setup Method, select override -> Select the event name -> Add the parameters that you want to send to FB API.

facebook capi tag for webhook

 

12. Set up a trigger for this tag. In my case, FB purchase will trigger when the request path equals /order_created and Client Name equals Data Client.

trigger for facebook capi webhook tag

 

13. Test Facebook CAPI tag.

facebook capi webhook tag triggered

facebook capi tag data in gtm server

 

14. If everything worked correctly, remove Preview Header that you’ve added on step #5 from the stape.io admin and publish changes you’ve made in the GTM server container. If you have any issues with the FB CAPI tag, check this blog post on how to test FB CAPI

Conclusion:

Data gathered from your CRM system can be sent to the Facebook conversion API with the help of webhooks. You do not need any coding knowledge for this process since it is done through the Google Tag Manager server container. 

 Ultimately, it means that the data from your CRM can become an excellent data source for FB custom audiences and conversions. And with stape.io, you can quickly test webhooks in the Google Tag Manager server container.

Want us to implement server-side tracking on your site?
Find out how much it'll cost!