> ## Documentation Index
> Fetch the complete documentation index at: https://docs.trueorigin.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# RevenueCat

> Count trials, conversions and revenue per campaign.

TrueOrigin reads your purchases from a RevenueCat webhook. Two parts: the webhook, and one
line in your app that ties RevenueCat's customer to the install.

## 1. Connect the webhook

1. In the dashboard, **Settings → RevenueCat → Connect RevenueCat**. You get a
   **Webhook URL** and an **Authorization header**. The header is shown once.
2. In RevenueCat, **Integrations → Webhooks**, add a webhook with that URL, and paste the
   whole header value, including `Bearer `, as the Authorization header.
3. Send all events.

No RevenueCat API key is needed. App Store events count; Android and web purchases arriving
on the same webhook are acknowledged and dropped.

If you lose the header, **Issue new credentials** in Settings and update it in
RevenueCat. The old header stops working at once.

## 2. Set the attributes in your app

After configuring both SDKs, and before any paywall:

<CodeGroup>
  ```swift Swift theme={null}
  Purchases.shared.attribution.setAttributes(TrueOrigin.revenueCatAttributes())

  // optional: campaign attributes for RevenueCat targeting, once attribution resolves
  TrueOrigin.onAttribution { attribution in
      Purchases.shared.attribution.setAttributes(attribution.revenueCatAttributes)
  }
  ```

  ```ts React Native theme={null}
  import Purchases from 'react-native-purchases'

  Purchases.configure({ apiKey: 'appl_…' })
  await Purchases.setAttributes(TrueOrigin.revenueCatAttributes())

  TrueOrigin.onAttribution(() => {
    Purchases.setAttributes(TrueOrigin.revenueCatAttributes())
  })
  ```
</CodeGroup>

Repeat the first call on every app start and after each successful RevenueCat `logIn` or
`logOut`. It returns right away, makes no network request, and always includes
`trueorigin_install_id`, even while the attribution is pending. It does not change the
RevenueCat App User ID; keep your own.

Once the install is matched, the attributes also carry the campaign:

| Attribute                                                  |                                                    |
| ---------------------------------------------------------- | -------------------------------------------------- |
| `trueorigin_install_id`                                    | Always. Ties RevenueCat's customer to the install. |
| `trueorigin_match_status`                                  | `matched`, `unmatched`, …                          |
| `trueorigin_media_source`                                  | The ad network.                                    |
| `trueorigin_campaign`, `trueorigin_adset`, `trueorigin_ad` | From the ad's [URL parameters](/tracking-links).   |

You can use them in RevenueCat for targeting and experiments.

## What gets counted

| RevenueCat event                                         | TrueOrigin           |
| -------------------------------------------------------- | -------------------- |
| Initial purchase with a free trial                       | Trial started        |
| First renewal after a trial                              | Trial converted      |
| Initial purchase without a trial, including intro offers | Subscription started |
| Other renewals                                           | Renewal              |
| Non-renewing purchase                                    | One-time purchase    |

Refunds are recorded too. The same events can go to Meta and TikTok as
[postbacks](/postbacks).
