# AppsFlyer, Adjust and Branch

> Send install attribution from AppsFlyer, Adjust or Branch to Herald, so each person carries their install source and campaign.

:::note Built and tested against each vendor's documented API; tell us if anything differs in your account.:::

Each postback becomes, for its user, the event `app_installed` (installs) or the vendor's event name (in-app events), with the attribution values as event properties. An install also sets these user attributes where present, so you can target a segment by install source.

| Attribute | AppsFlyer | Adjust | Branch |
|---|---|---|---|
| `install_source` | `media_source` | `network_name` | `last_attributed_touch_data.~channel` |
| `install_campaign` | `campaign` | `campaign_name` | `last_attributed_touch_data.~campaign` |
| `install_channel` | `af_channel` | none | `last_attributed_touch_data.~feature` |
| User id | `customer_user_id` | callback parameter `user_id` | `user_data.developer_identity` |
| Event time | `event_time` (UTC) | `created_at` (unix seconds) | `timestamp` (ms) |

A postback without a user id is skipped and counted. Replays are duplicates, because event ids are deterministic.

### Revenue

Purchases carry their value as the event properties `revenue` and `currency`, so an agent's goal can weight by value.

| Vendor | `revenue` and `currency` from |
|---|---|
| AppsFlyer | `event_revenue_usd` (as USD), else `event_revenue` and `event_revenue_currency`, else `revenue_in_selected_currency` and `selected_currency`. Add the field to the Push API endpoint |
| Branch | `event_data.revenue` and `event_data.currency` (USD when no currency was logged). `custom_data` becomes event properties too |
| Adjust | `{revenue_float}` (whole units), else `{revenue}` (cents), with `{currency}`. Both are in the callback URL the console shows |

There's no currency conversion except AppsFlyer's own USD field, so prefer it when your apps sell in several currencies.

## What you'll need

- An admin of the account. Integrations are set up in **Settings → Integrations**.
- **AppsFlyer:** access to the Push API, to add a custom header.
- **Adjust:** access to server callbacks.
- **Branch:** access to webhooks.
- Your own user id on each install: `customer_user_id`, the `user_id` callback parameter, or `developer_identity`.

## Connect

In **Settings → Integrations**, connect the provider and copy the URL and secret.

**AppsFlyer** (Push API). POST JSON with the custom header `Authorization: Bearer <secret>`. An install is `event_name` `install`. For an in-app event, `event_value` (a JSON string) becomes its properties.

**Adjust** (server callbacks). GET or POST to the callback URL the console shows. It carries the secret as `?s=` and these placeholders: `{activity_kind}`, `{adid}`, `{event}`, `{event_name}`, `{network_name}`, `{campaign_name}`, `{tracker_name}`, `{installed_at}`, `{created_at}`, `{revenue_float}`, `{revenue}`, `{currency}`. Add the global callback parameter `user_id` in the Adjust SDK. The activities `install` and `event` are used, and others are skipped. An unreplaced `{placeholder}` counts as missing. Only Adjust accepts GET.

:::warning Adjust callbacks cannot send headers, so the secret sits in the URL, where it can show up in Adjust's dashboard and in proxy or platform request logs. Herald's API never logs the query string. Keep the URL private and rotate the secret if it leaks.:::

**Branch** (webhooks). POST JSON with the header `Authorization: Bearer <secret>`. An install is `name` `INSTALL`.

## Troubleshooting

- **Everything is skipped.** The postback carries no user id. Send your own user id as `customer_user_id` (AppsFlyer), the `user_id` callback parameter (Adjust) or `developer_identity` (Branch).
- **Answers `401`.** The secret is wrong or the integration is paused. See [the overview](/docs/integrations/overview).

## Common errors

| Vendor | Message | Cause | Fix |
|---|---|---|---|
| All | `Unauthorized` | `401`: the secret is wrong, the integration is paused, or the URL names another provider | Copy the URL and secret again |
| AppsFlyer, Branch | `Unauthorized` | `401` for a GET: only Adjust may call with GET | Send POST |
| All | `Expected a JSON object` | `400`: the body isn't a JSON object | Use the vendor's postback, unchanged |
