# Report sales from your CRM

> Postbacks that tell the ad network when a lead closes.
> Source: https://www.eventsiq.io/docs/guide-crm-postbacks


Often you only learn that a lead became a sale days later. Tom Reed asks for a roof quote on Monday,
and your CRM marks the job sold on Friday. A postback is how your CRM tells EventsIQ, so the ad
network hears about it and can find more people like him.

This guide sets that up from start to finish.

:::note{title="What you'll need"}
-   A campaign that is already sending leads. If you do not have one, start with
    [Set up paid traffic](https://www.eventsiq.io/docs/guide-paid-traffic).
-   An ad account connected under **Connect → Connections**.
-   Your CRM set up as a [destination](https://www.eventsiq.io/docs/destinations), so it receives each lead.
-   A way to make your CRM call a link when a lead's stage changes. Ask whoever manages it.
:::

## What happens to one lead

Here is Tom's lead from click to sale, once everything below is set up. The ids and the key are
made up.

1. **Monday, the click.** Tom clicks your ad. EventsIQ gives the click an id, for example `abc123`,
   and he fills in your form.
2. **Monday, the lead reaches your CRM.** Your routing sends the lead to your CRM with
   `"click_id": "abc123"` in the body. Your CRM stores it with Tom's record.
3. **Friday, the sale.** Your CRM marks the job sold for $250 and calls your postback link:

   ```
   https://app.eventsiq.io/cv?click_id=abc123&event=sold&value=250&key=YOUR_KEY
   ```

4. **The reply.** EventsIQ finds the click, its campaign and the campaign's integration, and answers:

   ```json
   {"ok":true,"event":"sold","reported":"Purchase","sentAs":"conversion","value":250}
   ```

5. **What you see.** **Measure → Activity → Conversion logs** shows a **Postback: Sale closed** row, and the same
   line appears on Tom's lead in **Lead logs**. The ad network receives `Purchase` worth $250.

Reports do not change. Revenue there is what your destinations paid when they bought the lead, not
what your CRM reports later.

For an instant form lead there is no click, so step 2 sends `{{system.lead_id}}` and step 3 uses
`lead_id=` in place of `click_id=`.

## Step 1: Add your events

Events are your own names for the stages your CRM reports.

1. Go to **Settings → Postbacks** and click **Add event**.
2. **What to call it here**: a readable name, for example `Sale closed`.
3. **Name your CRM sends**: the word in the postback, for example `sold`.
4. **Value**: pick **What the CRM sends** if the amount changes per sale, **Same every time** if it
   does not (then fill in **Amount**), or **No value**.
5. Click **Save event**.

![The Postbacks page](https://www.eventsiq.io/docs-media/postbacks/01-page.png "Settings, Postbacks, with Your postback link at the top and Events your CRM sends below it. The key is shown as YOUR_KEY.")

Add one event for each stage you want to report, for example `appointment` as well as `sold`.

## Step 2: Say what the ad network receives

An event only reaches the network once a Conversion API integration has a row for it, and the
campaign has picked that integration.

1. Go to **Connect → Integrations** and open the **Conversion API** tab.
2. Open your integration. If you do not have one, click **New integration**, then **Set up** beside
   your network under **Conversion API**, and work through the steps.
3. On the step where you choose the pixel or ad account, find **Postback events** and click **Add**.
4. On the left, pick your event. On the right, set what the network should receive, for example
   `Purchase` on Meta.
5. Click **Save changes**. On a new integration, click **Next**, give it a **Name** on **Test and
   name**, and click **Create**.

![Postback events on an integration](https://www.eventsiq.io/docs-media/integrations/02-conversion-api.png "A Conversion API integration on the Pixel step, with Postback events rows mapping each event to what the network receives. Names blurred.")

Each network takes something different on the right. See [Integrations](https://www.eventsiq.io/docs/integrations).

Then point your campaign at the integration:

1. Go to **Capture → Campaigns**, open your campaign and click **Edit**.
2. On the **General** tab, pick the integration under **Report sales to**.
3. Click **Save changes**.

## Step 3: Connect your CRM

Your CRM can only report a click id it was given, so send it along with each lead first.

1. Go to **Destinations**, open your CRM and click the **Sending** tab.
2. Under **What to send**, click **Add a field**.
3. Under **Name**, type the name your CRM expects, for example `click_id`.
4. Pick **Text and details** and enter `{{runtime.eiq_click_id}}`.
5. Click **Save**. The button may name how many routing setups the change reaches.

Now give your CRM the link:

1. Go back to **Settings → Postbacks**.
2. Under **Your postback link**, click **Copy link**. It looks like this, with your real key in it:

   ```
   https://app.eventsiq.io/cv?click_id={click_id}&event=sold&value={value}&key=YOUR_KEY
   ```

3. In your CRM, have this link called when the lead's stage changes. Replace `{click_id}` and
   `{value}` with however your CRM writes those, and set `event` to one of your event names.

:::important{title="Instant form leads have no click"}
Facebook, TikTok, Google and Snapchat instant form leads never pass through a link, so they have no
click id. For those, use the link under **For instant form leads, which have no click**, send
`{{system.lead_id}}` in place of the token above, and pick the **Ad campaign** on your EventsIQ
campaign.
:::

:::caution{title="Treat the key like a password"}
Anyone with your key and a click id could report fake sales. If it leaks, click **Change key**. The
old link stops working at once, so update your CRM straight after.
:::

## Step 4: Test it

:::important{title="This reports a real event"}
A successful test sends the event to your ad network. Use a test lead of your own, and a small value.
:::

1. Go to **Measure → Activity → Lead logs** and open a test lead that came through your campaign's link.
2. Under **The click it came from**, copy the id at the bottom of the panel.
3. Run this, using your id and your key, or paste the same address into a browser:

   ```bash
   curl "https://app.eventsiq.io/cv?click_id=PASTE_CLICK_ID&event=sold&value=250&key=YOUR_KEY"
   ```

4. Read the reply. `"ok":true` with `"reported":"Purchase"` means EventsIQ accepted it and is sending
   it to the network. `"ok":false` comes with a `reason` that says why it was not sent.
5. Go to **Measure → Activity → Conversion logs**. You should see a **Postback:** row with your event's name.

:::tip{title="You're done when"}
The reply has `"ok":true`, and **Measure → Activity → Conversion logs** shows a **Postback:** row with your
event's name, for example **Postback: Sale closed**. Open the row to see what the network was sent.
:::

Run the same call again if you like. Each click reports each event once, so the second call sends
nothing, and the reply says it has already been reported. That is what stops a CRM that retries from
counting one sale twice.

## Troubleshooting

:::warning{title="The reply says Unauthorized"}
The key is wrong, or it was changed. Copy the link again from **Settings → Postbacks**.
:::

:::warning{title="The CRM says it sent, but Conversion logs shows nothing"}
Some refusals happen before EventsIQ knows which account the call is for, so only the reply says so.
Run the same call with `curl` and read `reason`. **The postback carried no click id or lead id**
means the CRM did not fill it in. **No click here matches that id** means the id is wrong, or from
another account. **That click produced no lead here** means the visitor clicked but never submitted.
:::

:::warning{title="A Postback row says nothing was sent"}
The row names the missing piece:

-   **No event of that name is set up here.** Add the event, or fix the spelling in the CRM.
-   **That event exists but is turned off.** Open it and turn on **Accept this event**.
-   **The campaign this click came from has no conversion integration.** Pick one under **Report sales
    to**.
-   **The campaign's conversion integration has no row for this event.** Add it under **Postback
    events**.
:::

:::warning{title="The value is missing"}
The event's **Value** is set to **No value**, or the CRM is not filling in `value`. Networks may
refuse `Purchase` without a value, and EventsIQ warns you about this on the row.
:::

## Where to go next

-   [Build your first waterfall (routing)](https://www.eventsiq.io/docs/guide-first-waterfall): add destinations and set what a sale looks like.
-   [Route leads by state](https://www.eventsiq.io/docs/guide-route-by-state): send each state to the destinations that serve it.
-   [Postbacks](https://www.eventsiq.io/docs/postbacks): other names for each part of the link, and every log reason.
-   [Integrations](https://www.eventsiq.io/docs/integrations): what each network receives.
