# How can I track campaign retargeting with AppsFlyer?

[AppsFlyer](https://www.appsflyer.com/) is extensive analytics that helps brands keep track of their attribution and engagement campaigns while providing a large variety of analytics.&#x20;

This client-side integration will allow you to retrieve Batch push notifications that opens in the Retargeting section as in the screenshot below:

<figure><img src="https://2998247023-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FbwlQFpRAhaFR79zae6Jf%2Fuploads%2FUREzS9DSKSPLeMaTGlxW%2FAttribution_Reporting_Appsflyer_Retargetting_14052025.png?alt=media&#x26;token=7dfc45bd-a7a3-4507-98cb-9bd8eb238da3" alt="Find your information in the retargeting section"><figcaption><p>Find your information in the retargeting section</p></figcaption></figure>

{% stepper %}
{% step %}

## Enabling AppsFlyer SDK to pick up opens

Follow the steps described in the official AppsFlyer documentation. The AppsFlyer SDK will be able to track push opens: [iOS](https://support.appsflyer.com/hc/en-us/articles/207032066-AppsFlyer-SDK-Integration-iOS) / [Android](https://support.appsflyer.com/hc/en-us/articles/207032126#tracking-push-notifications).
{% endstep %}

{% step %}

## Adding AppsFlyer data in the push payload <a href="#id-2-adding-appsflyer-data-in-the-push-payload" id="id-2-adding-appsflyer-data-in-the-push-payload"></a>

Simply add these few lines in your Batch Custom Payload to enable the notification to be tracked down by the AppsFlyer SDK:

{% hint style="danger" %}
*Please note that the payloads to be used for **iOS** and **Android** are not the same.*
{% endhint %}

### iOS <a href="#ios" id="ios"></a>

<pre><code><strong>{
</strong>   "data":{
      "af":{
         "pid":"batch_int",
         "is_retargeting":"true",
         "c":"test_campaign"
      }
   }
}
</code></pre>

### Android <a href="#android" id="android"></a>

```
{
     "af":{
         "pid":"batch_int",
         "is_retargeting":"true",
         "c":"test_campaign"
      }
}
```

Here is where you will need to paste the payload:

<figure><img src="https://2998247023-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FbwlQFpRAhaFR79zae6Jf%2Fuploads%2F7yYkmCkwNvGKdOH7nxqu%2FAttribution_Reporting_Appsflyer_payload_14052025.png?alt=media&#x26;token=fd2995e8-f356-491d-99b8-fd9077f6645c" alt="Insert your payload"><figcaption><p>Insert your payload in the right section</p></figcaption></figure>

Note that an extra step is needed on Android. You need to add the following code before calling the AppsFlyer `AppsFlyerLib.getInstance().sendPushNotificationData` method:

```
if (intent != null) {
```

```
  val batchPayload = intent.getBundleExtra(Batch.Push.PAYLOAD_KEY)
  val af: String? = batchPayload?.getString("af")
  if (batchPayload != null && af != null) {
    intent = intent.putExtra("af", af)
  }

}
```

{% endstep %}

{% step %}

## Record push notifications data on AppsFlyer <a href="#id-3--record-push-notifications-data-on-appsflyer" id="id-3--record-push-notifications-data-on-appsflyer"></a>

AppsFlyer allows you to record push notifications as part of retargeting campaigns by calling the methods documented here: [iOS](https://support.appsflyer.com/hc/en-us/articles/207032066-iOS-SDK-V6-X-integration-guide-for-developers#additional-apis-record-push-notifications) / [Android](https://support.appsflyer.com/hc/en-us/articles/207032126#additional-apis-recording-push-notifications)
{% endstep %}
{% endstepper %}
