# Meta Conversions API

> Send conversions from Datacenter to Meta with the Conversions API. Paste a pixel id and access token, mark goals, test with a test event code.

Source: https://datacenter.so/docs/meta-conversions-api
Section: Measure

The Meta Conversions API (CAPI) lets you send conversions to Meta from a server instead of only from the pixel in the browser. Blockers and short cookie lifetimes make the browser pixel miss sales. Server events fill the gap, and Meta can match them back to the ad.

Datacenter does the server part for you. You paste two values, mark which goals to send, and Datacenter sends them. It is on paid plans: Solo, Studio, Agency and Custom. Free does not include it.

## What you need

- A Meta pixel for your site. Meta also calls it a dataset.
- Its **pixel id**, a number.
- An **access token** for the Conversions API.

## Get the access token

1. Open [Meta Events Manager](https://business.facebook.com/events_manager2).
2. Pick your pixel (dataset) in the list on the left.
3. Open the **Settings** tab.
4. Scroll to **Conversions API** and find **Set up manually**.
5. Press **Generate access token**. Copy it right away. Meta shows it once.

The pixel id is at the top of the same Settings tab.

## Connect a site

1. Open the site in Datacenter, then **Settings**, then **Integrations**.
2. Under **Meta Conversions API**, paste the pixel id and the access token.
3. Press **Save**.

The token is encrypted before it is stored. Nobody can read it back in the dashboard, not even you. To replace it, paste a new one. **Disconnect** deletes it.

If the setup card says Meta sending is not switched on yet, the server is missing its encryption key. That is ours to fix, not yours.

## Choose what to send

In the same card, under **Goals to send**, tick each goal you want and pick its Meta event:

| Meta event | Use it for |
|---|---|
| `Purchase` | A paid order |
| `Lead` | A form or a quote request |
| `CompleteRegistration` | A signup |
| `AddToCart` | An item added to the cart |
| `InitiateCheckout` | The start of checkout |
| `Subscribe` | A paid subscription or a newsletter |
| `Contact` | A call, chat or email |
| Custom | Any other name, letters and digits |

Press **Save goals**. From then on, every match of the goal goes to Meta, from the browser and from the [Events API](https://datacenter.so/docs/events-api).

## What each event carries

- `event_name`, `event_time` and `event_id`.
- `action_source` set to `website`, and `event_source_url`: the page, without its query string.
- `client_ip_address` and `client_user_agent` of the visitor.
- `fbc`, from the `fbclid` on the landing page or Meta's `_fbc` cookie, and `fbp` from Meta's `_fbp` cookie, when present.
- `em` and `ph`: email and phone, normalized and SHA-256 hashed, when you sent them with the Events API.
- `external_id`: the SHA-256 hash of the visitor's first-party id, or of the `visitor.id` you sent.
- `value`, `currency` and `order_id`, when the event has them.

The raw email and phone never leave your server unhashed, and Datacenter never stores them.

## Count once with the pixel

If your pages also run the Meta pixel, both sides report the same signup or sale. Meta counts it once when both send the same event name and event id. Most sites need nothing for this: when the pixel sends an event with an id, the tag reads that id and the server copy goes to Meta with it.

Optional, only if your pixel calls send no event id: make one in the page and give it to both.

```js
const id = crypto.randomUUID();
fbq('track', 'Purchase', { value: 49, currency: 'USD' }, { eventID: id });
datacenter('Purchase', { event_id: id, value: 49, currency: 'USD' });
```

From your server, send the same id as `event_id` in the Events API. An order id works well, such as `order-1042`, if the page uses it too.

A goal on a page visit (such as `/thanks`) gets an id Datacenter makes up, which the pixel cannot know. Send that conversion from one side only.

## Refunds

Meta has no documented way to change or take back a sale once it is sent, and no refund event. So a refund is not sent to Meta, and Meta's revenue still counts the refunded sale. Datacenter's own [revenue](https://datacenter.so/docs/revenue-and-mrr) takes refunds off. Google Ads and Microsoft Ads do take refunds: see [Refunds](https://datacenter.so/docs/send-results-to-ad-accounts#refunds).

## Test it

1. In Events Manager, open your pixel, then the **Test events** tab.
2. Copy the test event code, such as `TEST12345`.
3. Paste it into **Test event code** in Datacenter and save.
4. Trigger the goal on your site. It shows in Meta's Test events tab within a minute.

While a test code is saved, Meta treats every event as a test. Remove the code when you are done.

## The delivery log

**Delivery log** lists the last 100 sends, newest first, with Meta's answer for each one. **Failed** shows only those that did not get through.

- Sends that fail for a passing reason (Meta busy, a network error) retry after 1, 2, 4, 8 minutes and so on, up to 6 hours apart, for 24 hours. Then they show as **Gave up**.
- Sends Meta refuses for good (a bad field) show as **Failed**.
- If Meta refuses the token, sends wait as **Waiting** until you save a new token. They then go out, if they are under 24 hours old.

The log never shows the token, the IP address or any email or phone.

## Consent

Sending the visitor's IP address, browser and click ids to Meta shares personal data with Meta. In the EU and UK this usually needs consent, whatever mode the site is in. With 90-day tracking and **Wait for consent** on, browser events go to Meta only after `datacenter('consent', true)`. See [Tracking modes](https://datacenter.so/docs/tracking-modes).

A browser that sends [Global Privacy Control](https://globalprivacycontrol.org/) (`Sec-GPC: 1`) is never sent to Meta, with or without consent. California treats the signal as an opt-out of the sale and sharing of personal data. With 90-day tracking, the signal stays with the visitor's random id for 13 months, so later sales tied to it are not sent either. Your own statistics still count the visit. See [Send results to your ad accounts](https://datacenter.so/docs/send-results-to-ad-accounts#global-privacy-control).

## Match quality

Meta matches better with more to go on. In Private mode, click ids live only for the visit, so a sale on a later day has no `fbclid`. Use [90-day tracking](https://datacenter.so/docs/tracking-modes) to keep click ids for 90 days, and send email or phone from your server with the [Events API](https://datacenter.so/docs/events-api).

## Google Ads

Google Ads has its own row under [Send results to your ad accounts](https://datacenter.so/docs/send-results-to-ad-accounts) (when shipped).
