Use case: automatically reward users based on events in the app¶
Overview¶
Reward users automatically based on the events inside the application. For instance, you can:
- Reward user for doing a certain action in the application, e.g., reaching level X, beating the high score.
- Reward user for being socially active, e.g.. posting on Activity Feed, sending Smart Invites.
- Provide a reward for inviting friends, only when they perform a certain action (reach the level, do the first IAP) in the app.
- Re-engage user after being in-active for some time, for instance you can send a notification with a special offer if user did not use the app for 7 days.
Implementation guide¶
As an example let’s implement rewarding user (User A) for inviting friends to the game, only when a friend (User B) installs the app and reaches level 5 in the game.
0. Prerequisite¶
-
Integrate GetSocial SDK. Check the detailed guide on Android, iOS or Unity.
-
Setup push notifications. Check the detailed setup guide on Android, iOS or Unity.
-
Allow inviting friends to the app. Integrate Smart Invites to provide User A a way to invite his friends. See the detailed guide for the SDK.
1. Automate rewarding¶
To automate rewarding, we have to let GetSocial know that User B reached level 5 and sent a notification with a reward attached to User A.
Prepare application to receive several reward types
To enable higher flexibility we recommend configuring an application in a way it can receive a couple of reward types. For instance, on the app side you can implement receiving “receive-gold-reward” and “receive-item-reward” and configure what reward will be given and “how much gold” or “what item” will be rewarded from the GetSocial Dashboard.
-
Inform GetSocial when the user performs the desired action. You have two options:
-
You can send a custom GetSocial Analytics event:
Analytics.trackCustomEvent("level_achieved", mapOf("level" to "5"))
Analytics.trackCustomEvent("level_achieved", properties: [ "level": "5" ])
var properties = new Dictionary<string, string> { {"level", "5"} }; Analytics.TrackCustomEvent("level_achieved", properties);
Map<String, String> properties = {'level': '1'}; Analytics.trackCustomEvent('level_achieved', properties);
const properties = { 'level': '5' }; Analytics.trackCustomEvent('level_achieved', properties);
const properties = { 'level': '5' }; GetSocialSDK.Analytics.trackCustomEvent('level_achieved', properties);
-
Or set a public user property:
val userLevel : String = ... ; // Get user level curentUser.updateDetails(UserUpdate().setPublicProperty("level", userLevel), { Log.d("CurrentUser", "User details were successfully updated") }, { error -> Log.d("CurrentUser", "Failed to update user details, error: ${error}") })
let level: String = ... // Get user level var update = UserUpdate() update.setPublicProperty(value: level, key: "level") GetSocial.currentUser().updateDetails(update, success: { print("User property successfully set") }, failure: { (error : Error) in print("Failed to set user property, error: \(error.localizedDescription)") })
string userLevel = ... ;// Get user level GetSocial.GetCurrentUser().UpdateDetails( new UserUpdate().SetPublicProperty("level", userLevel), () => { Debug.Log("User property successfully set"); }, error => { Debug.LogError("Failed to set user property, error: " + error.Message); });
var userLevel = ...; // Get user level var currentUser = await GetSocial.currentUser; var batchUpdate = UserUpdate(); batchUpdate.setPublicProperty('level', userLevel); currentUser.updateDetails(batchUpdate) .then(() => print('User property successfully set')) .catchError((error) => print('Failed to set user property, error: $error'))
const userLevel = ...; // Get user level const currentUser = await GetSocial.getCurrentUser(); const batchUpdate = new UserUpdate(); batchUpdate.publicProperties['level'] = userLevel; currentUser.updateDetails(batchUpdate) .then(() => console.log('User property successfully set')) .catch((error) => console.log('Failed to set user property, error: ', error))
const userLevel = ...; // Get user level const currentUser = GetSocialSDK.GetSocial.getCurrentUser(); const batchUpdate = new GetSocialSDK.UserUpdate(); batchUpdate.publicProperties['level'] = userLevel; currentUser.updateDetails(batchUpdate) .then(() => console.log('User property successfully set')) .catch((error) => console.log('Failed to set user property, error: ', error))
What approach is better depends on the nature of the event, for instance, reporting that user has beaten the high score is better done by tracking custom analytics event, tracking the current user level better suits for a public user property.
-
-
Automate reward using Smart Flows. Smart Flows is a GetSocial Dashboard feature that allow setting up automation of the various tasks using trigger-action rules. We have to set up a rule as follows:
- Trigger: listen for
level_achieved
event, when event occurs andlevel
property will be5
do an action. - Action: get the user who invited the current user, and send him a notification “Congrats, your friend reached level 5. Click to receive 500 coins as a referral bonus.”, attaching the data about the reward.
In other words, as soon as User B reaches level 5, the rule we set up above automatically trigger and send a notification with a reward to User A.
- Trigger: listen for
2. Receive notification¶
Receiving the notification and handling notification click to issue the reward is the same for all use cases. Please follow the “Receive notification” implementation guide in the Send/request access to group/clan/challenge/gifts use case for details.
Try it out¶
Download DevFest Ukraine conference application to check out the demo how to automate user rewarding for performing actions inside the app.