Track Referrals
Reward your players for referrals and grow your business

Introduction

One of the most effective ways to get new users is through user referrals. You can use Gameball referrals capabilities to encourage your users to invite their friends by offering rewards for successful referrals to both the referrer and the recipient.
Gameball referrals uses Firebase Dynamic Links in the background to generate players referral links and track referrals. Dynamic Links are smart URLs (deep links) that survive the app install process, so new referred users via referral links will be easily tracked when they open the app for the first time.
Gameball and its SDK provides hassle free integration to track referrals where you will only need to
    1.
    Provide your firebase info through Gameball dashboard to generate referral links to your players
    2.
    Invoke referral method with every new account creation through your app.
Your players will be able to get and share their referral link from Gameball Player Widget
Tracking referral requires Firebase and Firebase Dynamic Links SDKs installed into your app.

Integration Steps

To integrate and track referrals you need to perform two main steps
    1.
    Configure Firebase on your App and Gameball account dashboard
    2.
    Invoke SDK Referral method within your App user registration flow.

1. Firebase configuration

Set up a new Firebase project and install the Dynamic Links SDK into your app. Installing the Dynamic Links SDK allows Firebase to pass along data about the Dynamic Link to the app, including after the user installs the app.
    Import FireBase in AppDelegate File
1
import Firebase
Copied!
    Copy this code in you AppDelegate
1
func handleIncommingDynamicLink(_ dynamicLink: DynamicLink){
2
guard let url = dynamicLink.url else {
3
return
4
}
5
self.gameballApp?.recievedDynamicLink(url: url)
6
}
7
func application(_ application: UIApplication, continue userActivity: NSUserActivity, restorationHandler: @escaping ([UIUserActivityRestoring]?) -> Void) -> Bool {
8
if let incommingURL = userActivity.webpageURL {
9
let linkHandled = DynamicLinks.dynamicLinks().handleUniversalLink(incommingURL) { (dynamicLink, error) in
10
guard error == nil else {
11
return
12
}
13
if let dynamicLink = dynamicLink {
14
self.handleIncommingDynamicLink(dynamicLink)
15
}
16
}
17
return linkHandled
18
}
19
return false
20
}
21
22
func application(_ app: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey : Any] = [:]) -> Bool {
23
if let dynamicLink = DynamicLinks.dynamicLinks().dynamicLink(fromCustomSchemeURL: url){
24
self.handleIncommingDynamicLink(dynamicLink)
25
return true
26
} else {
27
return false
28
}
29
}
Copied!

2. Invoke SDK Referral method

friendReferral SDK methodThis should be called after your user registration, hence a new player is created. It basically detects if the user has registered using a referral code or not.
If you need to use a referral method to sign up a new player using a referral link, call the function below to use the referral module. Best use case is in the success of the registration API of your app.
Don’t call the registerPlayer, this method will register the new playerUniqueId
1
let playerAttributes: [String : Any] = [
2
"displayName": "John Snow",
3
"email": "[email protected]"
4
]
5
self.gameballApp?.friendReferral(playerUniqueId:"{{layer_unique_id}}" , playerAttributes: playerAttributes, completion: { result in
6
print(result)} )
Copied!
The playerAttributes is optional, so if you haven't created it yet then call the method like this with only the new playerUniqueId.
1
self.gameballApp?.friendReferral(playerUniqueId:"{{player_unique_id}}", completion: { result in print(result)
2
} )
Copied!
Last modified 2mo ago