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

# Measuring Referral Campaigns

You can use Airbridge tracking links to measure the performance of referral marketing initiatives, such as share-the-campaign and invite-a-friend campaigns, and identify users who refer your service to others to reward them accordingly.

## Referral Campaign User Scenario

Here is a typical user scenario using an Airbridge tracking link as a shareable link to measure a referral campaign:

1. User A clicks a CTA button, such as a **Share** button or **Invite a Friend** button. A link will appear that the user can copy and share with others. This link will contain the user ID that can be used to identify User A for rewards.

2. User A shares the link with User B through email or messenger.

3. User B clicks the link.

* When the app is not installed: User B is redirected to the app store where the app can be downloaded. By using deferred deep linking, User B can be redirected to a specific in-app location upon launching the app for the first time after the app install.
* When the app is already installed: The app is launched on User B’s device. By using deep linking, User B can be redirected to a specific in-app location.

4. User A can be rewarded after User B installs and launches the app or performs a certain app event.

## How to Use Tracking Links for Referral Campaigns

The following steps should be handled by a developer. Ask your developer for help.

1. Develop a CTA button so that when a user clicks the button, the [Tracking Link API](/en/references/tracking-link/create-tracking-link) is called. Make sure the user ID of the user who clicks the CTA button is included in the tracking link. The following parameters shall be used.

| <span style={{ display: 'inline-block', minWidth: '80px' }}>Parameter</span> | <span style={{ display: 'inline-block', minWidth: '200px' }}>Description</span>                                                                                                                                      |
| ---------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `channel`                                                                    | The channel name you wish to look up in the Airbridge reports and raw data files to find the data collected through the tracking link should be entered. This channel name will be considered a Custom Channel name. |
| `params`                                                                     | Campaign parameters such as `campaign`, `ad_group`, `content`, `term`, `sub_id` can be included to record additional campaign data.                                                                                  |
| `deeplinkURL`                                                                | The in-app destination and the user ID of the user who clicked the CTA button should be entered.                                                                                                                     |

For a sample request, refer to the example below.

<Accordion title="Tracking Link API Sample Request">
  ```json lines theme={"theme":{"light":"github-dark-dimmed","dark":"github-dark-dimmed"}}
  $ curl -d '{
    {
    "channel": "in_app_referral",
    "campaignParams": {
      "campaign": "referral-01",
      "ad_group": "referral",
      "ad_creative": "invitation"
    },
    "isReengagement": "Off",
    "deeplinkUrl": "ablog://good-product-growth-team?referrer_id=1668",
    "deeplinkOption": {
      "showAlertForInitialDeeplinkingIssue": true
    },
    "fallbackPaths": {
      "option": {
        "ios": "itunes-appstore",
        "android": "google-play"
      }
    },
    "ogTag": {
      ...
    }
  }
  }' -X POST "'https://api.airbridge.io/v1/tracking-links" -H "Authorization:{AIRBRIDGE-API-TOKEN} -H "Content-Type: application/json
  ```

  The above codes contains the following information.

  * `channel`: The referral campaign data collected through the tracking link should be made available under the channel name `in_app_referral` in the Airbridge reports and raw data files.
  * `params`: The campaign name should be recorded as `referral-01`, ad group name as `referrral`, and the ad creative name as `invitation`.
  * `deeplinkURL`: Users who click the tracking link should be redirected to `ablog://good-product-growth-team`. The user ID of the user who clicked the CTA button and created the shareable link is `1668`. If the user ID is 1700, the parameter value should be

    `ablog://good-product-growth-team?referrer_id=1700`.
</Accordion>

2. The tracking link should be provided to the user who clicks the CTA button as a shareable link. We recommend providing the `trackingLink.shortURL`parameter value from the [Tracking Link API response](/en/references/tracking-link#create-tracking-link-response) as the shareable link, which follows the format as follows.

* \{default or custom domain}/\{shortID}

To use your custom domain instead of `abr.ge`, which is the default setting, refer to this [article](/en/guides/custom-domain) and configure your custom domain in the Airbridge dashboard.

For a sample response, refer to the example below.

<Accordion title="Tracking Link API Sample Response">
  ```json lines theme={"theme":{"light":"github-dark-dimmed","dark":"github-dark-dimmed"}}
  {
      "data": {
          "trackingLink": {
              "id": 77281,
              "link": {
                  "click": "http://abr.ge/@airbridge/my-channel?...",
              },
              "shortID": "6nwx4w",
              "shortURL": "http://abr.ge/6nwx4w",
              "trackingTemplateID": "706f9839a7b50d87ab917dbb1b9fa7f3",
              "channelType": "custom"
          }
      },
      "at": 1585104275
  }
  ```

  Provide the `trackingLink.shortURL` parameter value as the shareable link to the user who clicks the CTA button.
</Accordion>

3. Configure the deep link callback to get the user ID of the user who clicked the CTA button. You can use the user ID to identify users who participated in your referral campaign and provide rewards.

<AccordionGroup>
  <Accordion title="Android">
    Set up the [deep link callback](/en/developers/android-sdk-v4#redirect-users-with-airbridge-deep-links) to parse the URI of the `onSuccess` function.

    * `referrer_id`: The user ID of the user who clicked the CTA button

    <CodeGroup>
      ```java Java lines theme={"theme":{"light":"github-dark-dimmed","dark":"github-dark-dimmed"}}
      Airbridge.getDeeplink(getIntent(), new AirbridgeCallback<Uri>() {
      	@Override
      	public void onSuccess(Uri result) {
      		// Parse the {result} parameter to get the referrer_id or any other parameter.
      	}
      }
      ```

      ```kotlin Kotlin lines theme={"theme":{"light":"github-dark-dimmed","dark":"github-dark-dimmed"}}
      Airbridge.getDeeplink(intent, object : AirbridgeCallback<Uri> {
      	override fun onSuccess(result: Uri) {
      		// Parse the {result} parameter to get the referrer_id or any other parameter.
      	}
      }
      ```
    </CodeGroup>
  </Accordion>

  <Accordion title="iOS">
    Set up the [deep link callback](/en/developers/ios-sdk-v4#enable-user-redirection-with-airbridge-deep-links) to parse the `deeplinkURL` parameter.

    * `referrer_id`

      : The user ID of the user who clicked the CTA button

    <CodeGroup>
      ```objective-c Objective-C lines theme={"theme":{"light":"github-dark-dimmed","dark":"github-dark-dimmed"}}
      [AirBridge.deeplink setDeeplinkCallback:^(NSString * _Nonnull result) {
      	// Parse the {result} parameter to get the referrer_id or any other parameter.
      }];
      ```

      ```swift Swift lines theme={"theme":{"light":"github-dark-dimmed","dark":"github-dark-dimmed"}}
      AirBridge.deeplink().setDeeplinkCallback { result in
      	// Parse the {result} parameter to get the referrer_id or any other parameter.
      }
      ```
    </CodeGroup>
  </Accordion>
</AccordionGroup>

## Event Collection

<Info>
  **Note**

  If you are using the DeepLink Plan, only data collected through the tracking links used in the referral campaign is available in the Airbridge dashboard. Note that user actions regarding sharing cannot be collected, and relevant metrics or GroupBys are not available to create a report.
</Info>

To properly measure your referral campaign, specific user actions relevant to the referral campaign, such as clicking the CTA button, should be collected as an Airbridge event. Such action can be collected as Share event (airbridge.share) which is a [Standard Event](/en/guides/airbridge-event-types#standard-events) or can be collected as a newly defined Custom Event.

If the Airbridge SDK is already collecting such user action and sending the events to Airbridge, no additional task is required. If not, however, you need to reconfigure the Airbridge SDK to collect such user action and send the events to Airbridge, conduct SDK testing, and release your app with the new Airbridge SDK.

Refer to the developer guides listed below for SDK configuration.

<Accordion title="Developer Guides for SDK configuration">
  | Platform      | Developer Guide                                                                                                                                                                      |
  | ------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
  | Android       | [Android SDK ](/en/developers/android-sdk-v4#in-app-events)<br />[Android SDK (Deprecated)](/en/developers/deprecated-android-sdk-v2#%EC%9D%B4%EB%B2%A4%ED%8A%B8-%EC%84%A4%EC%A0%95) |
  | iOS           | [iOS SDK](/en/developers/ios-sdk-v4#in-app-events)<br />[iOS SDK (Deprecated)](/en/developers/deprecated-ios-sdk-v1#in-app-events)                                                   |
  | Web           | [Web SDK](/en/developers/web-sdk#events)                                                                                                                                             |
  | React Native  | [React Native SDK](/en/developers/react-native-sdk-v4#in-app-events)<br />[React Native SDK (Deprecated)](/en/developers/deprecated-react-native-sdk-v2#event-setup)                 |
  | Cordova-Ionic | [Cordova-Ionic SDK](/en/developers/cordova-sdk-v4)<br />[Cordova-Ionic (Deprecated)](/en/developers/deprecated-cordova-ionic-sdk-v2#event-setup)                                     |
  | Flutter       | [Flutter SDK](/en/developers/flutter-sdk-v4#in-app-events)<br />[Flutter SDK (Deprecated)](/en/developers/deprecated-flutter-sdk-v3#in-app-events)                                   |
  | Expo          | [Expo SDK](/en/developers/expo-sdk-v4)<br />[Expo SDK (Deprecated)](/en/developers/deprecated-expo-sdk-v2#event-setup)                                                               |
  | Unity         | [Unity SDK](/en/developers/unity-sdk-v4#in-app-events)<br />[Unity SDK (Deprecated)](/en/developers/deprecated-unity-sdk-v1#event-setup)                                             |
  | Unreal        | [Unreal SDK](/en/developers/unreal-sdk-v4#in-app-events)                                                                                                                             |
</Accordion>

## Performance Reporting

The performance of your referral campaigns can be viewed in the Airbridge reports and raw data files. You can use the following metrics and GroupBys to visualize the data in the reports.

| Metric or GroupBy | Description                                                                                                                      |
| ----------------- | -------------------------------------------------------------------------------------------------------------------------------- |
| channel           | The channel name of the referral campaign. Shows the `channel` parameter value.                                                  |
| campaign          | The campaign name of the referral campaign. Shows the `campaign` parameter value. If not configured, no data is available.       |
| ad group          | The ad group name of the referral campaign. Shows the `ad_group` parameter value. If not configured, no data is available.       |
| ad creative       | The ad creative name of the referral campaign. Shows the `ad_creative` parameter value. If not configured, no data is available. |

## Attention

<AccordionGroup>
  <Accordion title="Campaign parameter settings">
    When calling the Tracking Link API, we recommend configuring the campaign parameters to collect detailed information on your referral campaign.
  </Accordion>

  <Accordion title="User ID">
    The user ID should be a unique identifier assigned to each user account of your service. Note that Airbridge does not manage the user IDs.
  </Accordion>
</AccordionGroup>

<link rel="alternate" hrefLang="en" href="https://help.airbridge.io/en/guides/referral-campaign-measurement" />

<link rel="alternate" hrefLang="ko" href="https://help.airbridge.io/ko/guides/referral-campaign-measurement" />
