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

# Airbridge attribution integration

> Use Airbridge attribution data to choose campaign recipients based on how they found your app.

> [!TIP]
>
> The Airbridge integration is available on Notifly's Pro and Enterprise plans.

## Overview

Save Airbridge attribution results as Notifly user properties. Then use those properties to choose who receives a campaign based on how they found your app.

## Attribution fields

| Field | Description |
| - | - |
| `attributedChannel` | Channel |
| `attributedCampaign` | Campaign |
| `attributedAdGroup` | Ad group |
| `attributedAdCreative` | Ad creative |
| `attributedContent` | Content |
| `attributedTerm` | Keyword |
| `attributedSubPublisher` | Sub-publisher |

## Set up the integration

Use the Airbridge SDK's attribution callback to receive results. In the callback, call `setUserProperties` in the Notifly SDK with the fields you want to save.

> [!NOTE]
>
> The Notifly SDK still requires the `password` argument for compatibility. Use the same nonempty value as `username`. Keep actual passwords and API Secret Keys out of app code.

### Prerequisites

Install the Airbridge and Notifly SDKs. Add the callback below to your app's existing SDK setup. On Android and iOS, register the callback in the Airbridge initialization options. Initialize Notifly before the callback can run.

> [tab] Android (Kotlin)
>
> ```kotlin title="MainApplication.kt" theme={null}
> import android.app.Application
> import co.ab180.airbridge.Airbridge
> import co.ab180.airbridge.AirbridgeOptionBuilder
> import co.ab180.airbridge.listener.OnAttributionResultReceiveListener
> import tech.notifly.Notifly
>
> class MainApplication : Application() {
>     override fun onCreate() {
>         super.onCreate()
>
>         Notifly.initialize(applicationContext, "PROJECT_ID", "USERNAME", "PASSWORD")
>
>         val option = AirbridgeOptionBuilder("YOUR_APP_NAME", "YOUR_APP_SDK_TOKEN")
>             .setOnAttributionReceived(object : OnAttributionResultReceiveListener {
>                 override fun onAttributionResultReceived(result: Map<String, String>) {
>                     val properties = mutableMapOf<String, Any>()
>                     result["attributedChannel"]?.let { properties["attributedChannel"] = it }
>                     result["attributedCampaign"]?.let { properties["attributedCampaign"] = it }
>                     result["attributedAdGroup"]?.let { properties["attributedAdGroup"] = it }
>
>                     if (properties.isNotEmpty()) {
>                         Notifly.setUserProperties(applicationContext, properties)
>                     }
>                 }
>             })
>             .build()
>
>         Airbridge.initializeSDK(this, option)
>     }
> }
> ```

> [tab] iOS (Swift)
>
> ```swift theme={null}
> import notifly_sdk
> import Airbridge
>
> func application(_ application: UIApplication,
>                  didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
>
>   Notifly.initialize(projectId: "PROJECT_ID", username: "USERNAME", password: "PASSWORD")
>
>   let option = AirbridgeOptionBuilder(name: "YOUR_APP_NAME", token: "YOUR_APP_SDK_TOKEN")
>     .setOnAttributionReceived { attribution in
>       var props: [String: Any] = [:]
>       if let v = attribution["attributedChannel"]  { props["attributedChannel"] = v }
>       if let v = attribution["attributedCampaign"] { props["attributedCampaign"] = v }
>       if let v = attribution["attributedAdGroup"]  { props["attributedAdGroup"] = v }
>
>       if !props.isEmpty {
>         Notifly.setUserProperties(userProperties: props)
>       }
>     }
>     .build()
>
>   Airbridge.initializeSDK(option: option)
>   return true
> }
> ```

> [tab] React Native
>
> ```javascript title="index.js (or App.js)" theme={null}
> import notifly from 'notifly-sdk';
> import { Airbridge } from 'airbridge-react-native-sdk';
>
> notifly.initialize({
>   projectId: 'PROJECT_ID',
>   username: 'USERNAME',
>   password: 'PASSWORD',
> });
>
> Airbridge.setOnAttributionReceived((attribution) => {
>   const props = {};
>
>   if (attribution?.attributedChannel) props.attributedChannel = attribution.attributedChannel;
>   if (attribution?.attributedCampaign) props.attributedCampaign = attribution.attributedCampaign;
>   if (attribution?.attributedAdGroup) props.attributedAdGroup = attribution.attributedAdGroup;
>
>   if (Object.keys(props).length) {
>     notifly.setUserProperties(props);
>   }
> });
> ```

> [tab] Flutter
>
> Add the attribution setup below to your existing `main()`. Keep your app's startup code, including `runApp()`. Import `package:flutter/widgets.dart` for `WidgetsFlutterBinding`.
>
> ```dart theme={null}
> import 'package:notifly_flutter/notifly_flutter.dart';
> import 'package:airbridge_flutter_sdk/airbridge_flutter_sdk.dart';
>
> Future<void> main() async {
>   WidgetsFlutterBinding.ensureInitialized();
>
>   await NotiflyPlugin.initialize(
>     projectId: 'PROJECT_ID',
>     username: 'USERNAME',
>     password: 'PASSWORD',
>   );
>
>   Airbridge.setOnAttributionReceived((Map<String, String> attribution) async {
>     final props = <String, Object>{};
>
>     final c = attribution['attributedChannel'];
>     final p = attribution['attributedCampaign'];
>     final g = attribution['attributedAdGroup'];
>
>     if (c != null) props['attributedChannel'] = c;
>     if (p != null) props['attributedCampaign'] = p;
>     if (g != null) props['attributedAdGroup'] = g;
>
>     if (props.isNotEmpty) {
>       await NotiflyPlugin.setUserProperties(props);
>     }
>   });
> }
> ```

## Campaign examples

* Send a welcome message to users whose `attributedChannel` is `Facebook`.
* Send a follow-up offer to users whose `attributedCampaign` matches a specific promotion.
* Use different messages for users who arrived through an ad channel and users whose `attributedChannel` is `unattributed`.

## FAQ

> [accordion] When does Notifly collect attribution data?
>
> The Airbridge SDK sends install attribution results to your app through a callback. The examples save the returned fields as Notifly user properties. Results can arrive after the app starts. If the app closes before receiving the results, the SDK may deliver them the next time the app opens.

> [accordion] Can I collect attribution data for users who already installed the app?
>
> This setup collects attribution for new installs after you add the Airbridge SDK.

> [accordion] What data does Airbridge return for an organic install?
>
> When there is no attribution result, Airbridge SDK v4 returns `attributedChannel` with the value `unattributed`. The code examples set only the properties for which they receive a value.

> [accordion] Can I use my own property names?
>
> Yes. You can change the names of the user properties you write in Notifly, such as `attributedChannel` and `attributedCampaign`. Use the same names when you refer to those properties in a Notifly campaign.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.