# AppsFlyer

## How It Works

If you use AppsFlyer, we recommend using an AppsFlyer link as your GrowSurf campaign Share URL.

This is the URL that referred friends land on when they open up a referral link. Depending on the device they open the link on (web, iOS, or Android), they will either land on a webpage or your App Store / Google Play listing on mobile.

When a participant shares their referral link, the GrowSurf referral code must stay attached to the AppsFlyer link. Your app then passes the AppsFlyer deep link or conversion payload into the GrowSurf mobile SDK before calling `addReferredParticipant()`.

***

## How to Set Up

**Step 1:** In GrowSurf, open *Campaign Editor > 5. Installation* and set your Share URL to the AppsFlyer OneLink URL that routes users to your app.

<figure><img src="/files/qtf4iEzsI41YZP2sU5RX" alt=""><figcaption></figcaption></figure>

**Step 2:** Configure the AppsFlyer link so the GrowSurf referral code is returned to your app:

{% stepper %}
{% step %}
In AppsFlyer, go to *Engage > OneLink Management > Edit Link* and create or edit the link you entered into your GrowSurf campaign.

<figure><img src="/files/v7PaOj9RA3hNUgmrF6Yt" alt=""><figcaption></figcaption></figure>
{% endstep %}

{% step %}
Scroll to the *Redirection* section and make sure that all the fields in iOS and Android redirection are set up properly.

<figure><img src="/files/eq3xXJJqXGIDsWvnUhyE" alt=""><figcaption></figcaption></figure>
{% endstep %}

{% step %}
Click the *Save template* button.

There's no need to set a custom attribution parameter because AppsFlyer will automatically preserve  `grsf` URL parameters in redirects.
{% endstep %}
{% endstepper %}

**Step 3:** Pass the AppsFlyer callback payload into the GrowSurf attribution adapter before calling `addReferredParticipant()`.

{% tabs %}
{% tab title="iOS" %}

```swift
import GrowSurfAppsFlyerAttribution

try await GrowSurfAppsFlyerAttribution.handle(appsFlyerParams, sdk: growsurf)
```

{% endtab %}

{% tab title="Android" %}

```kotlin
import com.growsurf.sdk.attribution.appsflyer.GrowSurfAppsFlyerAttribution

GrowSurfAppsFlyerAttribution.handle(appsFlyerConversionData, growsurf)
```

{% endtab %}
{% endtabs %}

**Step 4:** Call `addReferredParticipant()` after the GrowSurf SDK has handled attribution. This method will validate pending attribution and creates a new referred participant record only when there is a valid referrer.

***

## Additional Tips

* Test both flows before launching:
  * **Installed app flow:** Users who already have your app installed
  * **New install flow:** Users who don't have your app installed
* If the referral code is missing after app install, move it into an AppsFlyer deferred deep link field such as `deep_link_value` or `deep_link_sub1`.
* See [iOS SDK Attribution Providers](/developer-tools/ios-sdk/attribution-providers.md), [Android SDK Attribution Providers](/developer-tools/android-sdk/attribution-providers.md), and [Getting Started for Native Mobile](/getting-started-for-native-mobile.md) for more details.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.growsurf.com/integrations/appsflyer.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
