Skip to main content
Question

Get Branch "User Id"


Forum|alt.badge.img

Hello,

I am integration Branch with RC and I found this in RC documentation:

https://www.revenuecat.com/docs/integrations/attribution/branch#optional-set-a-separate-identity-in-branch-and-revenuecat

Quote:

If you prefer to keep a separate user identity between Branch and RevenueCat, set a $branchId Attribute in RevenueCat. If set, RevenueCat will use this identifier for Branch events instead of the App User Id.

 

I like that aproach and I would like to set $branchId with a user id from Branch, what how do I get it?

Could you please tell me which field I should use to set $branchId?

PS: if I don’t change/override/use any custom identity ids, so what comes from BranchSDK is not changed, I just want to pass it to RC as $branchId.

 

Thanks!

This post has been closed for comments

3 replies

kaitlin
RevenueCat Staff
Forum|alt.badge.img+6
  • RevenueCat Staff
  • 417 replies
  • July 9, 2025

Hey ​@NickA2B!

Once you have the ID from Branch, you can set this in RevenueCat for your user with the method `setAttributes`, passing the key `$branchID` (the $ is important, denoting this as a reserved attribute for Branch) and the value. For example, depending on the SDK you’re using:

Purchases.shared.attribution.setAttributes(["$branchId": "branch_user_id"])

Let me know if that works for you or if that’s not what you meant!


Forum|alt.badge.img
  • Author
  • New Member
  • 1 reply
  • July 10, 2025
kaitlin wrote:

Hey ​@NickA2B!

Once you have the ID from Branch, you can set this in RevenueCat for your user with the method `setAttributes`, passing the key `$branchID` (the $ is important, denoting this as a reserved attribute for Branch) and the value. For example, depending on the SDK you’re using:

Purchases.shared.attribution.setAttributes(["$branchId": "branch_user_id"])

Let me know if that works for you or if that’s not what you meant!

I think this might be a problem, I didn’t see that branch sends a proper “user_id” for Android.

 

Could you please verify that this code will properly connect Branch and RC:

  1. First I set Branch Identity to my device’s custom user id (deviceId)
  1. Then I set the same id to RC SDK ($branchId field).

 

This is Flutter App.

Thanks.


kaitlin
RevenueCat Staff
Forum|alt.badge.img+6
  • RevenueCat Staff
  • 417 replies
  • July 17, 2025

Hey ​@NickA2B,

Thanks for the update - your code looks good to me. I’m not super familiar with the Branch SDK and if they offer any additional identifiers for users for Android, but you can really set this ID to be anything you’d like if you’d prefer a separate identity to the app user id that you use for RevenueCat, including a device ID. 


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings