{"id":4968,"date":"2022-02-16T11:11:31","date_gmt":"2022-02-16T08:11:31","guid":{"rendered":"https:\/\/trackingchef.com\/?p=4968"},"modified":"2022-08-30T18:49:08","modified_gmt":"2022-08-30T15:49:08","slug":"creating-a-simple-conversions-api-for-your-facebook-pixel-events","status":"publish","type":"post","link":"https:\/\/trackingchef.com\/facebook\/creating-a-simple-conversions-api-for-your-facebook-pixel-events\/","title":{"rendered":"Creating a simple Conversions API for your Facebook Pixel events"},"content":{"rendered":"\n

One of the frequent recommendations in preparation for Apple’s PCM<\/a> and their AEM, is to move all events to the Server Side (Server to Server, or S2S) using Facebook’s Conversion API (aka CAPI).<\/p>\n\n\n\n

This is indeed a highly recommended practice, that usually proves to increase both the count of events logged and their accuracy in attributing to the correct campaign. It’s also a common practice for large-scale ecommerce sites using Google Analytics, using a similar tool called Measurement Protocol.<\/p>\n\n\n\n

While a full-blown S2S implementation requires your developer to make significant changes to your back-end, you can still reap some of its benefits without investing countless developer hours.<\/p>\n\n\n\n

If you’re using WooCommerce, the popular PixelYourSite plugin has the Conversions API<\/a> events already baked into the platform (for Purchase events only at this time).<\/p>\n\n\n\n

If you aren’t using WooCommerce, or want to pass other events too, you can use this guide to do so.<\/p>\n\n\n\n

Pro tip:<\/strong>
If you’re having your development team build an internal Conversions API solution, have them look at our code too, it will help them overcome Facebook’s complex documentation.<\/p><\/blockquote>\n\n\n\n

Important note\u200b<\/h2>\n\n\n\n

This guide will help you build a CAPI solution that is utilizing the key concepts of the API but is built as a client-side solution. This means you won’t get the full benefits of the CAPI (mainly overcoming ad blockers) but can expect an increase of 5-10% in the number of events tracked<\/strong>, resulting in larger audiences to target in your campaigns (e.g. more users recorded that added to their carts).<\/p>\n\n\n\n

Facebook even released this case study with “Love your Melon”<\/a> which showed a 17% increase in attributed revenue <\/strong>after switching to the Conversions API.<\/p>\n\n\n\n

Overview<\/h2>\n\n\n\n

This solution is built to use the existing data objects you already have in your client-side, via JavaScript, Google Tag Manager, or any other method, and transfer them to Facebook via API.<\/p>\n\n\n\n

It basically has two parts:<\/p>\n\n\n\n

  1. The client-side script that captures the user details<\/li>
  2. The server-side setup to process the data and pass it to Facebook<\/li><\/ol>\n\n\n\n

    To keep things (relatively) simple, I’ve used a setup created on Pipedream<\/a> that removes the need to understand anything too technical or set up an actual server for this. They offer quite a generous free tier, that can handle 100k events\/month, so most sites should be able to use this for setting up this CAPI solution.<\/p>\n\n\n\n

    The Pipedream workflow contains three simple steps:<\/p>\n\n\n\n

    1. Incoming webhook – Used to collect the data sent from the user’s browser<\/li>
    2. Node.js function – Used to format the data before sending<\/li>
    3. HTTP Post request – Used to send the data to Facebook’s API<\/li><\/ol>\n\n\n\n

      Step 1 – Get your Facebook data ready\u200b<\/h2>\n\n\n\n

      To create the CAPI integration you will need two values: Your Pixel ID and its Access Token.<\/p>\n\n\n\n

      Getting the Pixel ID\u200b<\/h3>\n\n\n\n