Firebase
Setting up Firebase Deeplinks and integrating the same with CustomerGlu
  • Log into your firebase account
  • Go to Dynamic Link section
  • Click on Add URL Prefix
  • Enter the domain name you want to create. From the drop-down select a Google-Provided domains Eg: <domain-you-entered>.page.link
  • Share the WebAPI key with CustomerGlu from your firebase console. It can be found Settings > General> Web API Key
  • Share following with CustomerGlu
    • androidPackageName for android apps
    • iosBundleId for ios apps
    • iosAppStoreId for ios apps
    • Default URL to redirect to if opened from outside ios or android ecosystem
    • Web API Key see above
    • URL Prefix see above eg: <domain-you-entered>.page.link
Please refer to the following documentation for receiving and processing the referral links Android: https://firebase.google.com/docs/dynamic-links/android/receive iOS: https://firebase.google.com/docs/dynamic-links/ios/receive The referlink that you extract will be of the format https://<default-url>/?userId=<referrer'sUserId>&referralCode=<code> You can extract this userId by parsing the query parameter of the deepLink like so,
1
// Android
2
String referrerUserId = deepLink.getQueryParameter("userId");
3
4
//iOS
5
let queryItems = URLComponents(url: deepLink, resolvingAgainstBaseURL: true)?.queryItems
6
let referrerUserId = queryItems?.filter({(item) in item.name == "userId"}).first?.value
Copied!

referredBy

Store the referrer userId information and pass it as referredBy property in the device registration call for the new user:
1
{
2
"userId": "<new-user-Id>",
3
"deviceId": "asd",
4
"deviceName": "TestDevice",
5
"deviceType": "android",
6
"writeKey": "write-key",
7
"firebaseToken": "firebase-token",
8
"referredBy": "referrerUserId"
9
}
Copied!
Note: On installation where there is no referrer, you need not send referredBy property in the call

referralCode

Store the referral code information and pass it as referralCode property in the device registration call for the new user:
1
{
2
"userId": "<new-user-Id>",
3
"deviceId": "asd",
4
"deviceName": "TestDevice",
5
"deviceType": "android",
6
"writeKey": "write-key",
7
"firebaseToken": "firebase-token",
8
"referralCode": "ABC-123"
9
}
Copied!
Note: On installation where there is no referrer, you need not send referralCode property in the call

Processing referral from registration/app download web page

If your app is not available in the play/app store and you have an app download flow via a webpage, please follow the below steps
  • Provide download page URL to CustomerGlu, eg: https://testclient.com/register
  • When a user clicks on the referralLink he will be redirected to the default URL provided to us with referrer's userId appended as a query parameter. eg:
    • https://testclient.com/register?userId=userA
  • Extract the referrer's userId from the url and make the deviceRegistration call to our server with
    • New user's userId
    • Referred user's userId as referredBy or referral code as referralCode
    • other details that are available
1
{
2
"userId": "userB",
3
"userName": "New User",
4
"referredBy": "userA",
5
"phone": "932339089012489",
6
"email": "[email protected]"
7
"customAttributes": {
8
"custom_attr_1": "asdas"
9
},
10
"writeKey": "<writeKey>"
11
}
Copied!
  • Once the user installs the app and is registered with the same userId (eg: userB in this case), his referral information will be attached to the new user
Last modified 3mo ago