Using the Facebook Conversions API (CAPI) to track conversions


This custom scenario is in beta, we reserve the right to make super useful changes and improvements in the future.

With Facebook you're likely used to tracking using the Javascript "pixel" code.

This is fine and all, but it relies on cookies and/or the user being logged in, and is not usable in situations where an offer/advertiser only supports postback URL tracking of conversions.

Using the Facebook S2S API is convenient and accurate, and now can be set up relatively easily. You can still use the pixel for tracking everywhere, but if you want to use the S2S API to track conversions/purchases, don't double-up the pixel tracking there (i.e. don't place FB Pixel JS on the conversion page and use postbacks to send conversions to FB too, as you can get duplicates).

To do this you're going to need a few things:

  1. A Business Manager account in Facebook
  2. A Facebook Pixel set up
  3. Access to the events manager, where you'll get an access token
  4. A few minutes to set things up

Testing and priming events

Annoyingly, if you don't have event data sent already, your event doesn't come up as "active" and you can't select it in your campaign. A bit of chicken and egg no?

To help with this, I have made a pixel-priming page for you.

Replace the XXX with your pixel ID and load this page. The page should say the ID that was loaded, and you have a number of buttons that will trigger Facebook pixel events.

  1. Use the above URL with your pixel ID included in it
  2. Load this URL in your browser normally and click each button 3-5 times to spam them with some events
  3. In the Facebook events manager section, you should eventually see these event stats

Once you have done the above, all these events should appear as active for the pixel in your campaign setup, allowing you to select them as optimisation events.

Step 1: Create a FB App/Access Token

This part is mainly up to you.

Firstly, check Facebook's documentation here.

You will need to go through a few steps, assuming you already have a FB pixel set up.

  1. Go to then to Data Sources > Pixels
  2. Select your pixel, then click Open in Events Manager
  3. Click the Settings Tab, then scroll down to Conversions API > generate access token:

Once this generates a token, copy and store this in a text editor for later use.

Step 2: The Right Traffic Source Setup

Now that we have that sorted, lets make sure the Facebook traffic source in FunnelFlux is configured correctly.

You can simply use our template, which gives this under the tracking fields area:

Note above we have "fbclid" set for the external field with no placeholder. This means it won't appear in the links we generate, but since FB will automatically append it, we will capture it in redirect links and direct links to your pages.

Step 3: Conversion Tracking Setup

Head to the conversion tracking tab. Pick custom scenario > Facebook.

You will see a form like so:

 Here you will need to:

  • Paste the access token you got from Facebook
  • Place your pixel ID as well
  • Set an event name -- for now you can only use one, which must be a standard event -- see the "Event Name" column here

Optionally, you can also:

  • Send a test event code, so that you can use Facebook's event manager section to check the integration is working
  • Send a specific URL for each conversion instead of the offer's URL.

We know that one challenge with this integration right now, particularly for affiliates, is that the event URL sent must be a verified domain. Unless you have had the domain shared to you by the advertiser, this simply won't be the case.

We are working on a solution that will allow you to pass the initial lander/page URL instead, which should be available soon.

Guide: Manual Self-Testing

Its very difficult to fully test this before setting it live, as we need real FBCLIDs else the Facebook API will reject the calls.

However, you can test this by getting a direct link to one of your offer pages, with FB set as the source (generate a direct link via the Funnel Builder).

Then in FB messenger send it to yourself in chat. This will generate a link preview.

Open the link in a new incognito window and you should see it redirect to your page with fbclid=xxx in the URL.

Go to the Raw Events section and load data for that funnel/source, check that you see a Hit to the offer with the FBCLID captured. If so, great!

Now in the FB Business Manager, head back to the event manager > pixels section and the Test Events page. You want to find your test code:

You can toggle on the test event code option in the custom scenario settings, then paste this test code value.

Be sure to remove this before going live as otherwise all events will be test events.

Now, go back to the Raw Events page, double click the offer hit ID to copy it, go to the update conversions section and paste it > update.

If all goes well, you should see the event come up in the test events section in FB.

Intended Updates


We will update our templates to select and better populate the custom scenario section (right now you still have to manually swap to it, and there are no obvious links to this documentation).

Data Passing

Under the custom data part of conversions, we plan to pass:

  • funnel_id -- the funnel ID (already done)
  • offer_id -- the ID of the converting offer
  • offer_cat -- the category of the converting offer
  • txid -- the transaction ID of the conversion (already done)

This data will allow you to create custom conversions/audiences based on the funnels/offers that are sending conversions, which will allow you to separate events more clearly on the Facebook side.

Page URL Overrides

We are aware that sending the offer URL is not always ideal.

We are working on a page URL override feature that will allow passing a URL to your offer/network, then sending that back in any conversion tracking to tell our system to use a different URL from the offer URL.

Our goal here is allowing you to pass the URL of the initial page the user landed on -- not necessarily a lander, but just the first page from the ad click -- because this has the highest chance of being a page under your control.

We unfortunately can't simply add a new token to postbacks/custom scenarios like {first-page-visited} because its not practical to query a single row in our analytics database for every conversion, to look up a related value. But, we have a solution in mind!

Custom Events

When we add custom events to our system, we would allow you to define different event names to send to Facebook for each of these events. E.g. custom event 1 (alias lead) --> send event name CompleteRegistration, etc.

Was this article helpful?