Facebook integration
Two separate things, set up in the same place:
- Conversions API — Roitrack reports conversions to your pixel from the server, so they arrive even when the browser never comes back. Ad blockers, iOS restrictions and closed tabs stop browser-side pixel events; a server-side event is not affected by any of them.
- Ad spend — Roitrack reads what Facebook charged and writes it onto your clicks, so cost and ROI fill themselves in.
You can use either one without the other. Reporting conversions does not need a token that can read spend, and pulling spend needs neither the Conversions API nor a pixel on your links.
1. The Facebook traffic source
A traffic source named Facebook is created for you, with its macros already filled in:
| Sub | Name | Macro |
|---|---|---|
sub1 | Campaign ID | {{campaign.id}} |
sub2 | Campaign name | {{campaign.name}} |
sub3 | Adset ID | {{adset.id}} |
sub4 | Adset name | {{adset.name}} |
sub5 | Ad ID | {{ad.id}} |
sub6 | Ad name | {{ad.name}} |
sub7 | Placement | {{placement}} |
sub8 | Site source | {{site_source_name}} |
Pick it as the traffic source on your campaign. If you delete it, it stays deleted — it is not recreated on the next update.
2. Save your pixel and token
Settings → Integrations → Facebook → Add pixel.
| Field | Where it comes from |
|---|---|
| Pixel ID | Events Manager → your pixel |
| Name | Optional — which ad account this is, so you can tell rows apart |
| Access token | Events Manager → your pixel → Settings → Conversions API |
Credentials live here rather than on each campaign because the pixel comes from the ad URL, not from campaign settings. One campaign can feed several ad accounts, and rotating a token is one edit instead of one per campaign.
3. Put the pixel on your link
Add ?pixel= to the tracking URL you paste into the ad:
https://your-tracking-domain.com/click/<token>?pixel=1234567890&sub1={{campaign.id}}&sub3={{adset.id}}&sub7={{placement}}That is how each click knows which pixel it belongs to. When a conversion arrives, Roitrack looks that pixel up in your saved list and sends the event with the matching token. No saved token for that pixel means nothing is sent — silently, because there is nothing sensible to do with a conversion for a pixel you have not configured.
Facebook appends fbclid to your destination URL by itself, so match quality works without any extra setup.
Improving match quality with fbp (optional)
_fbp is a cookie your own pixel sets on your lander, so only a page running your pixel can read it. If you use a lander, append it to the CTA link and match rates improve:
<a href="{LP_URL}" id="cta">Get started</a><script> var fbp = document.cookie.match(/_fbp=([^;]+)/); if (fbp) { var a = document.getElementById("cta"); a.href += (a.href.indexOf("?") > -1 ? "&" : "?") + "fbp=" + fbp[1]; }</script>Skip this on direct-to-offer campaigns — there is no page of yours for the cookie to be set on.
4. Choose which events to report
On the campaign, with the Facebook traffic source selected, switch on Facebook Conversions API, then Open settings.
Each row maps one of your events to one Facebook event:
- Conversion — your main postback, the one your network fires on a sale
- Event 1 – Event 10 — your custom postback events
Send them as Purchase, Lead, CompleteRegistration, Subscribe, StartTrial, InitiateCheckout, AddToCart, ViewContent or any other standard event.
Start with no rows: nothing is sent until you add at least one. The mapping saves with the campaign’s Save button, like every other campaign setting.
A common setup is one row — Conversion → Purchase. Add more when your network fires distinct events you want optimised separately.
5. Pull ad spend (optional)
Reading spend needs a different permission than reporting conversions. A Conversions API token usually cannot do it.
Settings → Integrations → Facebook → Ad spend. Paste one token carrying
ads_read and save it. That is the whole configuration.
There is no ad account ID to fill in, and one token covers your entire business
portfolio however many ad accounts it holds. Spend is read per Facebook
campaign, and the campaign IDs are already on your clicks — put there by the
{{campaign.id}} macro on the built-in traffic source. The tracker only asks
about campaigns that actually sent you traffic, so a portfolio with a hundred
accounts costs the same handful of requests as one with a single account.
Then press Check. It reports how many ad accounts the token reaches, which is the question that matters: a system user token authenticates perfectly well with no assets assigned to it, and reads nothing. It also lists any currencies that will be converted — see below.
Finally, on the campaign, switch on Pull cost from Facebook. Spend is read hourly and spread evenly across that day’s clicks. Pull cost now, on the integrations screen, runs it immediately.
What to expect
- Recent days are re-read. Facebook keeps restating a day’s spend for around three days after it — invalid-click credits, currency settlement, late impressions. Roitrack re-reads the last few days on every pass and replaces the cost rather than adding to it, so numbers settle instead of doubling.
- Cost is spread evenly across the day’s clicks. It is a daily total divided by that day’s traffic, not a per-click figure from Facebook, because Facebook does not report per-click cost.
- Campaigns the token cannot see are reported, not counted as zero. If your token is not assigned to the ad account holding a campaign, the sync says so by name instead of quietly recording no spend for it.
- Currencies are converted to US dollars. Each ad account is billed in its own currency; spend is converted and then summed, so a campaign spanning several accounts adds up to something meaningful. Reports are in dollars throughout — this converts ad spend, not your payouts, which are assumed to be in dollars already.
Checking it works
For conversions: fire a test conversion through your postback URL, then open Events Manager → your pixel → Test events or the activity log. A server event appears with the event name you mapped. If nothing arrives, work through:
- Is the Conversions API switch on for that campaign?
- Is at least one event mapped? An empty mapping sends nothing.
- Did the click carry
?pixel=, and is that exact pixel ID saved under Settings → Integrations? - Is the conversion less than seven days after the click?
For spend: press Check under Ad spend. It should report the number of ad accounts your token reaches — if that number is lower than you expect, the missing accounts are not assigned to this system user. Then Pull cost now and open any report for yesterday: cost should be populated. Today’s figure moves as the day goes on, which is expected.