Skip to content

Using the Facebook Conversions API (CAPI) to track conversions

With Facebook you are likely used to tracking with the JavaScript “pixel” code. The pixel relies on cookies and/or the user being logged in, and you cannot use it when an offer or advertiser only supports postback URL tracking of conversions.

The Conversions API sends conversions server-to-server, and you can set it up in a few steps. FunnelFlux sends each conversion to a relay at functions.funnelflux.pro, which passes it to Facebook.

You can still use the pixel for tracking everywhere else. If you use the Conversions API to track conversions or purchases, do not also fire the pixel there: placing Facebook Pixel JS on the conversion page and sending conversions to Facebook by postback can create duplicates. The client-side ways to fire the pixel are in Triggering Facebook conversion pixels.

You need:

  1. A Meta Business Suite (Business Manager) account
  2. A Facebook Pixel (called a dataset in Events Manager)
  3. Developer access to that pixel in Events Manager, where you generate an access token

Step 1: Generate a Conversions API access token

Section titled “Step 1: Generate a Conversions API access token”

Meta’s Conversions API get-started documentation describes the Events Manager method, which Meta recommends.

Assuming you already have a Facebook pixel set up:

  1. Open Events Manager from https://business.facebook.com/ and choose the pixel you want to use.
  2. Select the Settings tab.
  3. Find the Conversions API section and click Generate access token under Set up manually, then follow the pop-up instructions.

Meta only shows the Generate access token link to users with developer privileges for the business.

Once Facebook generates a token, copy it and store it somewhere safe for later use.


Next, make sure the Facebook traffic source in FunnelFlux is configured correctly. We recommend starting from the template and modifying it afterwards.

Add Traffic Source window named Facebook Ads with its tracking fields and an added tracking field fbclid with the placeholder token DELETE_ME

In the example setup:

  • Load the Facebook Ads template.
  • Add a new tracking field.
  • Set “fbclid” as the name.
  • Set “DELETE_ME” as the placeholder value.

Facebook automatically appends fbclid to clicks. You do not want to add it to your links, but you need to define it here so that FunnelFlux captures it and stores it in the database.

When you generate links, whether a redirect link or a direct URL for JS tracking, remove the fbclid=DELETE_ME part from the URL or the optional URL params box. The all-caps value is a clear reminder to do this, so that your links stay clean and do not conflict with Facebook’s automatic data passing.


Scroll down to the conversion tracking part of the traffic source and select Postback URL.

The postback URL is long, so build it in a text editor. Place the following in a text editor:

https://functions.funnelflux.pro/facebook-s2s-api?fbclid={trackingfield-fbclid}&funnel_id={funnel-id}&hit_id={flux_hid}&vid={flux_hid}&revenue={flux_payout}&currency=USD&page_url={page-url}&ip={connection-ip}&user_agent={connection-useragent}&entrance_timestamp={unix-timestamp}&conversion_timestamp={unix-timestamp}&txid={flux_txid}
&access_token=ACCESS_TOKEN_HERE
&pixel_id=PIXEL_ID_HERE
&event_name=EVENT_HERE

Then:

  • Replace ACCESS_TOKEN_HERE with the access token you copied from Facebook.
  • Replace PIXEL_ID_HERE with the ID of your Facebook pixel.
  • Replace EVENT_HERE with an event name. You can only use one, and it must be a standard event: see the “Event Name” column in Facebook’s standard events reference.
  • Remove the line breaks before the final three lines, so that it is a single URL string.

Optionally, send a test event code so that you can use Facebook’s Events Manager to check the integration is working. To do this, append &test_event_code=OPTIONAL to the end of the URL (see the testing section below).

One challenge with this integration, particularly for affiliates, is that the event URL sent must be on a verified domain. Unless the advertiser has shared the domain with you, it will not be.

You can instead change &page_url={page-url} to a hard-coded lander URL on a verified domain. FunnelFlux currently has no token for passing the initial page visit, so this has to be set by hand.

If you do this, URL-encode the value. For example, instead of:

&page_url=https://google.com

pass:

&page_url=https%3A%2F%2Fgoogle.com

You can encode values with https://www.urlencoder.org/.


It is difficult to fully test this before going live, because Facebook’s API rejects calls without real FBCLIDs.

You can test it this way:

  1. Generate a direct link to one of your offer pages in the Funnel Builder, with Facebook set as the source.

  2. Send the link to yourself in Facebook Messenger. This generates a link preview.

  3. Open the link in a new incognito window. It should redirect to your page with fbclid=xxx in the URL.

  4. Open Stats, then Drilldown (Flat), and load a report of traffic source, node type, node name, hit ID, time, and URL tracking field. This gives you a log where you can identify your own offer hit and see the FBCLID in the URL tracking field column for that hit.

  5. In Events Manager, open your pixel and go to the Test Events tab, and copy your test event code.

  6. Make sure you have added this code as &test_event_code=XXX in the postback. Remove it before going live, otherwise all events will be test events.

  7. Open the Updates menu, then Conversion Updates. Paste your hit ID and submit it as a conversion.

If everything works, the event appears in the Test Events section in Facebook.

Facebook’s conversion script must run on the computer of the person who converted, that is, client-side.

Here is how it works in the case of Facebook:

  1. Someone clicks your ad.
  2. Facebook drops a cookie on that person’s computer.
  3. That person browses different pages on your site or the vendor’s site.
  4. When they purchase the offer, they land on a page with Facebook’s pixel.
  5. Facebook checks the cookie dropped in step 2 to connect the conversion to the clicked ad.

When you use a server-to-server postback, the affiliate network’s server that calls the postback does not have that cookie, because that server did not click the ad. So even if the script runs, Facebook cannot connect the conversion to the user who clicked the ad.

Ways to trigger the Facebook conversion pixel

Section titled “Ways to trigger the Facebook conversion pixel”

You cannot trigger Facebook pixel scripts through a server-to-server postback, but there are a few alternatives.

Place the Facebook conversion code on your thank-you page

Section titled “Place the Facebook conversion code on your thank-you page”

If the affiliate network or offer lets you place HTML/JS, place the code directly on the thank-you page, independent of your tracker (or the image pixel if they only allow that).

Fire conversions back to the traffic source using an iFrame

Section titled “Fire conversions back to the traffic source using an iFrame”

Go to Sources > Traffic Sources and edit your Facebook traffic source. If you don’t have one, click Add Traffic Source and pick the Facebook Ads template from Use template. Under Postback Type, select JavaScript, then paste your Facebook conversion pixel into JavaScript Code. When you use the JavaScript postback type, you must place the conversion iFrame on your thank-you page or exit page. Open the Links menu, then System Links, and copy the code from the Conversion iFrame card. Each copy regenerates a fresh pixel salt. This lets FunnelFlux inject client-side code, in this case Facebook’s JS code. If you use multiple pixels or accounts and need to fire a different code for different funnels, put that code in the funnel’s Advanced Settings, under Traffic source postback overrides, with the type set to JavaScript.

If you don’t have permission to add the Facebook conversion pixel to the thank-you or exit page (where the offer conversion happens), try the following.

You can trigger Facebook tracking by placing your Facebook conversion code in a JavaScript node in your funnel diagram, next to your conversion action link. To add one, right-click the canvas and choose Advanced > Add JS Code.

Funnel canvas with the FB AddToCart JavaScript node between the Widget Review lander and the Widget Pro offer

This fires JS before users reach the offer page. It lets you track at least click-throughs or add-to-cart events, though these are not as valuable as the end conversion. If you have upsells, this does let you track the first offer conversion.

If you cannot place JavaScript on the offer conversion point (the page that loads when a conversion happens), there is no way to pass this data to Facebook. This is a key limitation of client-side tracking and of the restrictions advertisers place on marketers.

Many advertisers and product owners now let marketers place Facebook tracking codes on their pages. Some ask only for your pixel ID so they can send events to it directly.