Build With RevenueCat

Build a customized mobile subscription business with RevenueCat. We do the heavy lifting of normalizing subscribers from any source and maintain a single source of truth for subscription status, so you can get back to building your app.

RevenueCat is a powerful, secure, reliable, and free to use in-app purchase server with global support. All you need to get started is an API key.

Get Started    REST API Endpoints

Branch

Integrate Purchases SDK with Branch for precise revenue tracking

With our Branch integration you can:

  • Accurately track subscriptions generated from Branch campaigns, allowing you to know precisely how much revenue your campaigns generate.
  • Send trial conversions and renewals directly from RevenueCat to Branch, allowing for tracking without an app open.
  • Continue to follow your cohorts for months to know the long tail revenue generated by your campaigns.

🚧

You're viewing outdated documentation

Head over to the latest version of the docs to see the new Branch integration guide: https://docs.revenuecat.com/docs/branch

1. Set Branch user identity

In order to attach attribution data to the correct user, make sure the App User Ids for RevenueCat and Branch match. The easiest way to do this is to set the Branch SDK identity to match the Purchases App User Id whether you're providing your own ids or using our randomly generated ids.

If you prefer to keep a separate user identity between Branch and RevenueCat, use the networkUserId parameter when adding attribution to specify the Branch user ID to attach to.

πŸ“˜

Install the Branch SDK

You will need to add the Branch SDK to your app before you can connect it with RevenueCat

// login
Branch.getInstance().setIdentity("my_app_user_id")

// logout
Branch.getInstance().logout()
// login
[[Branch getInstance] setIdentity:@"my_app_user_id"];

// logout
[[Branch getInstance] logout];
// login
Branch.getInstance().setIdentity("my_app_user_id");

// logout
Branch.getInstance().logout();
// login
branch.setIdentity("my_app_user_id")

// logout
branch.logout()

2. Send attribution data to RevenueCat

When you initialize a Branch session use the addAttributionData method for passing the attribution data dictionary in the callback:

Attaching attribution data to a user

import Branch
...
Branch.getInstance().initSession(launchOptions: launchOptions) { (data, error) in
    if let data = data {
        Purchases.addAttributionData(data, from: .branch)
    }
}
#import "Branch/Branch.h"
...
[[Branch getInstance] initSessionWithLaunchOptions:launchOptions
                        andRegisterDeepLinkHandler:^(NSDictionary *data,
                                                     NSError *error) {
  [RCPurchases addAttributionData:data 
                         fromNetwork:RCAttributionNetworkBranch];
}];
Branch branch = Branch.getInstance(getApplicationContext());
branch.initSession(new BranchReferralInitListener(){
    @Override
    public void onInitFinished(JSONObject referringParams, BranchError error) {
        if (error == null) {
          Purchases.addAttributionData(referringParams, 
                                       Purchases.AttributionNetwork.BRANCH);
        } else {
            Log.i("MyApp", error.getMessage());
        }
    }
}, this.getIntent().getData(), this);
branch.subscribe(({ error, params }) => {
  if (error) {
    console.error('Error from Branch: ' + error)
    return
  }

    Purchases.addAttributionData(params, Purchases.ATTRIBUTION_NETWORKS.BRANCH)
})

❗️

Remove SDK Purchase Tracking

Make sure to remove all client side tracking of revenue. Since RevenueCat will be sending events for all revenue actions, tracking purchases with the Branch SDK directly can lead to double counting of revenue in Branch.

3. Send RevenueCat events into Branch

After you've set up the Purchase SDK to send attribution data from Branch to RevenueCat, you can "turn on" the integration and configure the event tokens from the RevenueCat dashboard.

  1. Navigate to your app in the RevenueCat dashboard and choose 'Branch' from the integrations menu
  2. Add your test key and live key from Branch
  3. Enter the event names that RevenueCat will send or choose the default event names
  4. Select whether you want RevenueCat to report proceeds (after app store cut) or revenue (gross sales)

Branch configuration screen

πŸ‘

You've done it!

You should start seeing events from RevenueCat appear in Branch

Updated 5 months ago


Branch


Integrate Purchases SDK with Branch for precise revenue tracking

Suggested Edits are limited on API Reference Pages

You can only suggest edits to Markdown body content, but not to the API spec.