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

# Attribution

> Track where installs come from with PlaytoliaAttribution

Attribution tells you where your players came from: which ad, campaign, or channel drove each install. You pick a provider in Playtolia Settings, and the SDK resolves attribution at startup so you can read it from C# or save it to the player's account.

### Providers

| Provider      | What it does                                                                                                                   | Platforms    |
| ------------- | ------------------------------------------------------------------------------------------------------------------------------ | ------------ |
| **None**      | Attribution is off.                                                                                                            | Any          |
| **System**    | Reads the Google Play install referrer (UTM parameters plus click and install timestamps). No third-party SDK or token needed. | Android      |
| **Airbridge** | The Airbridge MDP SDK for full attribution and deferred deep links. Needs an app name and token.                               | Android, iOS |

<Info>
  The **System** provider has no iOS equivalent, so `GetInstallReferrer()` returns `null` on iOS. If you need cross-platform attribution, use **Airbridge**.
</Info>

### Enable attribution

Navigate to **Edit → Project Settings → Playtolia Settings**, open the **Attribution** section, and choose a provider. Changes take effect with the next build.

Selecting a provider reveals its options:

* **Store as Account Attribute** (all providers): see below.
* **Airbridge App Name / App Token / Sandbox** (Airbridge only): your Airbridge credentials.

### Reading attribution in Unity

```c# theme={null}
using PlaytoliaSDK.Runtime;
using Playtolia.Entity.Attribution;

// Google Play install referrer (Android, System provider)
InstallReferrerInfo referrer = PlaytoliaAttribution.GetInstallReferrer();
if (referrer != null)
{
    Debug.Log(referrer.ReferrerUrl); // "utm_source=google-play&utm_medium=organic&..."
}

// Parsed campaign data (works for any provider)
AttributionData data = PlaytoliaAttribution.GetAttributionData();
if (data != null)
{
    Debug.Log($"{data.Source} / {data.Medium} / {data.Campaign}");
}
```

Both methods return `null` when attribution has not resolved yet, or when the provider does not apply to the current platform.

**`InstallReferrerInfo`**

| Field                           | Description                                                                 |
| ------------------------------- | --------------------------------------------------------------------------- |
| `ReferrerUrl`                   | Raw referrer query string, e.g. `utm_source=google-play&utm_medium=organic` |
| `ReferrerClickTimestampSeconds` | When the referrer link was clicked (epoch seconds)                          |
| `InstallBeginTimestampSeconds`  | When the install began (epoch seconds)                                      |
| `GooglePlayInstant`             | Whether the player arrived through Google Play Instant                      |

**`AttributionData`**

| Field      | Parsed from    |
| ---------- | -------------- |
| `Source`   | `utm_source`   |
| `Medium`   | `utm_medium`   |
| `Campaign` | `utm_campaign` |
| `Term`     | `utm_term`     |
| `Content`  | `utm_content`  |

### Store as account attribute

With **Store as Account Attribute** enabled (the default), resolved attribution is saved to the player's account under the `install_referrer` key the first time they sign in. It is written once per player, so it captures the acquisition source without overwriting it on later logins.

This makes attribution available server side for segmentation and reporting, even if you never read it in-game.

<Note>
  The player must be authenticated before the attribute can be saved. If attribution resolves before sign-in, the SDK stores it automatically on the next login.
</Note>

### Using Airbridge

To use the **Airbridge** provider:

1. Add the Airbridge SDK to your project (Android: `io.airbridge:sdk-android`; iOS: the `Airbridge` pod).
2. Select **Airbridge** in Playtolia Settings and fill in your **App Name** and **App Token**.
3. Enable **Sandbox** only while testing.

<Warning>
  Attribution is skipped at runtime if the App Name or Token is empty. Double-check both fields before shipping.
</Warning>

<CardGroup cols={2}>
  <Card icon="bullhorn" href="/for-unity/promotions" title="Promotions">
    Review prompts and engagement
  </Card>

  <Card icon="bell" href="/for-unity/push-notifications" title="Push Notifications">
    Cross-platform notifications
  </Card>
</CardGroup>
