# Send MMP Attribution

Host apps can send Mobile Measurement Partner (MMP) data for direct app attribution in the `metadata` parameter when calling the [`install()` method](https://docs.digitalturbine.com/dt-ignite/ignite-services/sdk-reference/install-app).

You can send attribution data for the following mobile measurement partners:

* Adjust
* AppsFlyer
* Singular

{% hint style="warning" %}
Direct app attribution requires DTIS SDK version 4.0 or later *and* Reignite version 21.2 or later on the device. If you are using an older version of either the SDK or Ignite, attribution attempts return as errors.
{% endhint %}

## Bundle Attribution Data <a href="#h_01j838bb5t5kdk0hnaktpegs14" id="h_01j838bb5t5kdk0hnaktpegs14"></a>

Bundle MMP attribution data and send it in the `metadata` parameter when calling the [`install()` method](https://docs.digitalturbine.com/dt-ignite/ignite-services/sdk-reference/install-app).

To bundle MMP data:

1. Create an empty bundle.

{% code title="Kotlin" %}

```kotlin
val metadataBundle = Bundle()
```

{% endcode %}

2. Send attribution data for all apps as `SdkConstants.AttributionData` constants.

{% code title="Kotlin" %}

```kotlin
/*
 * Send Attribution data for one App or multiple Apps
 * To send Attribution data for multiple apps, create multiple attributionData objects (attributionDataApp1, attributionDataApp2, etc.)
 */
val attributionDataApp1 = mapOf(
    SdkConstants.AttributionData.MMP_NAME to etMmpNameValue,
    SdkConstants.AttributionData.MMP_PROVIDER to etMmpProviderValue,
    SdkConstants.AttributionData.MMP_TRANSACTION_ID to etMmpTransactionIdValue,
    SdkConstants.AttributionData.MMP_LINK to etMmpLinkValue
)
```

{% endcode %}

| PARAMETER        | DESCRIPTION                                       | SAMPLE DATA                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      | REQUIRED FOR |     |     |
| ---------------- | ------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------ | --- | --- |
| `MMP_NAME`       | Name of mobile measurement partner.               | <p><code>AppsFlyer</code><br><code>Adjust</code><br><code>Singular</code></p>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    | Yes          | Yes | Yes |
| `MMP_PROVIDER`   | Name of provider.                                 | `Adjust`                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         | Yes          | No  | No  |
| `TRANSACTION_ID` | MMP Transaction ID for attribution.               | `3e456bj7f89065s433`                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             | No           | Yes | No  |
| `MMP_LINK`       | Fully populated tracking URL. Do not use aliases. | <p><code><https://app.adjust.com/17cokf03?campaign=WoodySort_Android_20630_MX_Multi_IGNITE_CPI&#x26;adgroup=15792&#x26;id2=dltSWkJQ&#x26;idfa=&#x26;gps_adid_lower_sha1=cceb917745519888862b3b5e4390df0a49c27ef0&#x26;android_id=&#x26;subpublisher_id=%5BSUBSITE_ID%5D&#x26;digital_turbine_referrer=APPIA112272313849595687647011480182574916004&#x26;cost_type=CPI&#x26;cost_amount=0.14&#x26;cost_currency=USD></code> </p><p></p><p><code><https://tactile.sng.link/D196p/g7w3?pcn=LG%3AUS%3AA%3A01%3ADTGrowth&#x26;psid=12903&#x26;cl=APPIA98303053034660451540383180027752312312&#x26;id2=dl5XWUJU&#x26;aifa=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx&#x26;test_an=digitalturbine></code></p> | Yes          | No  | Yes |

3. Create an attribution data map that associates the package name or URI with the corresponding attribution data.

{% code title="Kotlin" %}

```kotlin
override fun onSuccess(result: InstallationResponse) {
    Log.d(TAG, "Install application onSuccess(): taskId=${result.taskId}, appId=${result.applicationId}, package=${result.packageName}")   
 
    toast("Installed successfully Attibution Data Saved = ${result.application.attributionDataStorageSuccess} and Error = ${result.application.errorMessage}")
}
```

{% endcode %}

4. Add the map to the bundle. For example, the following example provides the `MMP_ATTRIBUTION_DATA` key for the `attributionDataMap` map.

{% code title="Kotlin" %}

```kotlin
metadataBundle.putSerializable(
    SdkConstants.AttributionData.MMP_ATTRIBUTION_DATA,
    attributionDataMap
```

{% endcode %}

## Attribution Results <a href="#h_01j838bb5tar0ny43gzpkj7x9t" id="h_01j838bb5tar0ny43gzpkj7x9t"></a>

Ignite sends the results of attribution data to the MMP in the `result.application` object in the `onSuccess` callback. If either the Host App uses an unsupported version of the SDK or the device uses an unsupported version of Ignite, DT sends an error message to the `onSuccess` callback.

{% code title="Kotlin" %}

```kotlin
override fun onSuccess(result: InstallationResponse) {
    Log.d(TAG, "Install application onSuccess(): taskId=${result.taskId}, appId=${result.applicationId}, package=${result.packageName}")   
 
    toast("Installed successfully Attibution Data Saved = ${result.application.attributionDataStorageSuccess} and Error = ${result.application.errorMessage}")
}
```

{% endcode %}

| PARAMETER                       | TYPE    | DESCRIPTION                                                                                                                                                                                                                          |
| ------------------------------- | ------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `attributionDataStorageSuccess` | Boolean | <p>Indicates whether DT was able to store attribution data after successful installation:</p><ul><li><code>TRUE</code> = Attribution data saved successfully.</li><li><code>FALSE</code> = Attribution data was not saved.</li></ul> |
| `errorMessage`                  | String  | If attribution data is not saved successfully, this string provides information on the error.                                                                                                                                        |
