Referral program
Want an effective way to attract new customers? Use referral programs to work for you. Referral marketing is a great way to reach out to future customers while engaging your current ones to endorse your brand. A win-win benefit for both parties.
Referral programs are one of the most powerful tools in building your sales by encouraging your customers to share something valuable with their friends. The power of a customer recommending your product to their friends is undeniable. When they do, they not only help you win business, but also increase awareness of your brand, which ultimately helps you reap big profits.
This use case describes the process of creating a refferal program by which current users of a mobile app can refer it to their friends and earn additional loyalty points for this action.
The main principles of the referral program:
Referrer
An active user of the application can refer it by distributing its unique code among friends and will receive 500 loyalty points as a reward.
The list below contains the business assumptions this use case is based on:
- A unique code is generated for each active app user, which they can share with their friends as a part of the referral program. In order to see their code, users must verify phone number first. Only after the phone number is correctly verified, the code is displayed in the user’s account.
- A user can only receive 500 loyalty points when the invitee downloads the app, makes a purchase for min. $20, and has a verified phone number.
- A user can recommend the app to a maximum of 3 people. When as all 3 invited users make a purchase, the referrer receives points (3x500) and the code section disappears which means the user can no longer continue to refer the app.
- Loyalty points can only be awarded to the referrer.
- The referrer is informed each time after receiving loyalty points for referring the application through a mobile push.
Invitee
- A new user does not receive additional loyalty points for using the provided code.
- The new user must have a verified phone number for the referrer to receive loyalty points.
To simplify naming in this use case, in further steps of the process referrer will be represented as user 1
and invitee will be described as user 2
.
Prerequisites
- Implement loyalty programs basics
- Integrate Synerise mobile SDK in your mobile application.
- Implement mobile pushes in your mobile application.
- Configure mobile push notifications
Process
In this use case, you will go through the following steps:
- Create an aggregate that counts the sum of all user transactions.
- Create a segment of users who meet the requirements of the referral program.
- Create an expression that determines the number of points awarded for each referral.
- Create an expression to determine the maximum number of points to be awarded.
- Create a workflow that generates a unique referral code for the user 1.
- Create a workflow that adds referral points to user 1.
- Create an expression that calculates the number of points left.
- Prepare a mobile push notification.
- Create a workflow that assigns the number of codes awarded to user 1.
Create an aggregate that counts the sum of all user transactions
In this part of the process, create an aggregate that returns the sum of all transactions a user made. This aggregate will be used to describe a condition (an invited user must spend at least $20, so the referring person can receive loyalty points for a referral) in a segmentation that will be created in further part of the proces.
- Go to Analytics > Aggregates > Create aggregate.
- As the aggregate type, select Profile.
- Enter the name of the aggregate.
- Click Analyze profiles by and select Sum.
- From the Choose event dropdown list, select the transaction.charge event.
- As the event parameter, select $revenue.
- Set the period from which the aggregate will analyze results to Lifetime.
- Save the aggregate.
Create a segment of users who meet the requirements of the referral program
The conditions that user 2 must meet include:
- execution of transactions for a minimum of $20,
- verification of the phone number,
- user 1 can receive loyalty points for a successful referral of a friend only once - the last condition is a security feature: webhook.response with the addition of points to user 1 can not occur more than 1 time.
- Go to Analytics > Segmentations v2 > New Segmentation.
- Enter the name of the segmentation.
- Choose Add condition and find the aggregate counting the sum of all user transactions, created in the previous step.
- From the Choose operator dropdown, choose Number, and then select More or equal to.
- In the next field, enter the required transaction value, in our case it is
20
. - Choose Add condition and find phoneVerified tag.
- From the Choose operator dropdown, choose Is true.
- Choose Add condition and find webhook.response event.
- Click the + where button, from the Choose parameter dropdown menu, choose name.
- From the Choose operator dropdown, choose Contain.
- In the next field, type
add points to user 1
. - Change the Performed action to Not performed by clicking the Performed word.
- Set the period from which the aggregate will analyze results to Lifetime.
- Save the aggregate.
This segmentation will be used in a workflow that assigns loyalty points to user 1.
Create an expression that determines the number of points awarded for each referral
In this part of the process, create an expression that will later be used to assign a defined number of points to user 1 for an application referral. In our case, each user receive 500 points for each referral.
- Go to Analytics > Expressions > New expression.
- Enter the name of the expression.
- Leave the Expression option at default (Attribute).
- Click the Select button.
- Choose # Constant.
- Open the settings of Constant value by clicking
0
. - In the field below, type
500
- Click Save.
Create an expression to determine the maximum number of points to be awarded
In this part of the process, you will create an expression that determines the maximum number of points that can be awarded to user 1. In our case, it is 1500 points. This expression will be used to calculate the number of points remaining for user 1.
- Go to Analytics > Expressions > New expression.
- Enter the name of the expression.
- Leave the Expression option at default (Attribute).
- Click the Select button.
- Choose # Constant.
- Open the settings of Constant value by clicking
0
. - In the field below, type
1500
- Click Save.
Create a workflow that generates a unique referral code
In this part of the process, you will create a workflow that will generate a unique referral code for both new users who are about to join the application and existing ones, which will be stored in the my_referral_code attribute. In addition, you will generate a special attribute that will be used to count the number of codes granted to user 1 - referral_points_received.
- Go to Automation > Workflows > New workflow.
- Enter the name of the workflow.
Define the trigger nodes
Configure the conditions that will trigger the workflow. In this case, you will run a workflow for new users who are just joining the application and for existing users for whom the code has not been generated yet.
Define the Profile Event node
- As the first node of the workflow, add Profile Event. In the configuration of the node:
- From Choose event dropdown menu, choose
client.add
event.
- From Choose event dropdown menu, choose
- Confirm by clicking Apply.
Define the Audience node
- Add the Audience node.
- In the configuration of the node, leave the value of the Run trigger option at default (one time).
- In Define audience, choose New Audience and click Define conditions.
- As the first condition, from Choose filter dropdown menu, choose
anonymous_type
attribute. - From the Choose operator dropdown list, select Equal.
- Result: A text field appears.
- In the text field type
NONE
.Note: Theanonymous_type
attribute determines whether the profile is anonymous or recognized. By selecting the valueNONE
, you will include only recognized users. - Click Choose filter and from the dropdown list, select my_referral_code.
- From the Choose operator dropdown list, select Boolean - Is true.
- Change the Profiles matching attribute option to Profiles not matching attribute by clicking the matching word.
- Click Apply.
- As the first condition, from Choose filter dropdown menu, choose
Add the Merge Paths node
Join the paths of the triggers created in the previous step by adding a Merge Paths node.
Configure the Delay node
- Add the Delay node. In the node settings:
- In the Delay field, type
3
. - From the dropdown list, choose Second.
- In the Delay field, type
- Click Apply.
Define the Profile Filter node
In this step, you will check whether the user passing this workflow already has the my_referral_code attribute assigned to their profile. If the user does not have the my_referral_code attribute, it will be generated in the next step of the workflow. If the user already has this attribute assigned, the flow ends.
- Add the Profile Filter node.
- In the settings of the node, click Choose filter and from the dropdown list, select my_referral_code.
- As the Operator, choose Boolean - Is false.
- Click Apply.
- Add the End node to the unmatched path from the Profile Filter node.
Define the Update Profile node
In this part of the process, you will create an attribute my_referral_code for users who do not have this attribute yet.
- The attribute value with a unique referral code will be generated using the Jinjava code presented in the following steps.
- The generated code will be used by user 1 to invite friends to the application.
For later tracking of points received by user 1, an additional attribute is added - referral_points_received, which is initially assigned the value 0
, since the user has not yet received points for the referral.
-
Join the matched paths from the Profile Filter node with the Update Profile node.
-
From the left dropdown list, select Attributes > my_referral_code.
-
From the right dropdown list, select Change.
-
In the text field, add Jinjava that will generate a unique reference code for user 1 based on the user’s unique client ID.
Note: For security reasons, we do not publish any examples. In case you need any support in creating such a unique mechanism, do not hesitate to contact us, we will be happy to help. -
Click Add field and from the dropdown list, select Attributes > referral_points_received
-
From the right dropdown list, select Change.
-
In the text field, enter
0
. -
Click Apply.
-
Select the End node.
Create a workflow that adds referral points
In this part of the process you will create a workflow that will add points to user 1 if all the necessary conditions are met, such as:
- user 2 has made a transaction for a minimum of $20,
- user 2 has a verified phone number,
- user 1 has not exceeded the limit of the possible number of referrals (3 referrals).
- Go to Automation > Workflows > New workflow.
- Enter the name of the workflow.
Define the trigger nodes
Configure the conditions that will trigger the workflow. In this case, the workflow is triggered for invited users who have already verified their phone number or completed a transaction. Meeting both conditions will also be checked in a further step of the workflow.
Define the Profile Event node
- As the first node of the workflow, add Profile Event. In the configuration of the node:
- From Choose event dropdown menu, choose
transaction.charge
event.
- From Choose event dropdown menu, choose
- Confirm by clicking Apply.
Define the Profile Event node
- Add Profile Event. In the configuration of the node:
- From Choose event dropdown menu, choose
client.addTag
event. - Click the + where button, from the Choose parameter dropdown menu, choose name.
- From the Choose operator dropdown, choose Equal.
- In the next field, type
phoneVerified
.Note: The tag name shown in this case is only an example. You can use any other tag that is dedicated to recognizing a verified phone number.
- From Choose event dropdown menu, choose
- Confirm by clicking Apply.
Add the Merge Paths node
Join the nodes defined in the previous step into a single path using the Merge Paths node.
Configure the Delay node
- Add the Delay node. In the node settings:
- In the Delay field, type
10
. - From the dropdown list, choose Second.
- In the Delay field, type
- Click Apply.
Define the Profile Filter node
In this step, you will verify if all conditions have been met in order to assign points to user 1 . If not, the workflow ends for a user.
- Add the Profile Filter node.
- In the settings of the node click Choose filter and from the dropdown list, select the segmentation you already created in this step.
- As the Operator, choose Boolean - Is true.
- Click Apply.
Define the Outgoing Integration node
In the Outgoing Integration node, you will create a webhook that will find the user to whom the points should be assigned - user 1.
Outgoing Integration will be performed only for users who meet the conditions defined in the Profile Filter node, otherwise the flow is finished - to the Not matched path from the Profile Filter node, add the End node.
- Add the Outgoing Integration node for the matching path.
- In the Definition section, choose the Custom webhook tab.
- In the Webhook name field, enter a name for the webhook. In this case
find user 1
. - Select the GET method.
3. In the URL of the endpoint, enter
https://api.synerise.com/crm/v1/list?search=my_referral_code:{{client.friends_referral_code}}
.
Note: We are looking for a profile in Synerise whose attribute value corresponds to the referrer. - In the Authorization section, select by API key as your method of authorization.
- From the dropdown list below, select your API key.
- Click Apply.
Define the Event Filter node
In this step, you will check whether:
- user 1 has been found,
- user 1 has already reached the maximum number of possible points received from the referral program,
- there are no phone fraud tags for this user (the number of that user isn’t used in more than one profile).
- As the next node, add Event Filter. In the configuration of the node:
- In the Check field, leave the default value without limits.
- In the Define conditions field, from the Choose event dropdown menu, choose
webhook.response
event. - Click the + where button, from the Choose parameter dropdown menu, choose name.
- From the Choose operator dropdown, choose Equal.
- In the next field, type
find user 1
. - From the Choose parameter dropdown menu, choose body.customers[0].referral_points_received.
Note: In order for such a parameter to appear in the webhook.response options, you need to launch the automation at least once for a test user.
- From the Choose operator dropdown, choose Less or equal.
- In the next field, type
3
- Confirm by clicking Apply.
Define the Outgoing Integration node
In this Outgoing Integration node, you will create a webhook that sends the points.upcharge event that adds points to user 1.
-
Add the Outgoing Integration node for the matching path.
-
In Definition section, choose the Custom webhook tab.
-
In the Webhook name, field enter a name for the webhook. In this case
add points to user 1
. -
Select the POST method.
-
In the URL of the endpoint, enter
https://api.synerise.com/v4/events/custom
. -
In the headers section:
- set
content-type
value toapplication/json
- set
accept
value toapplication/json
- define
api-version
to4.4
- set
-
Enter the request body. The structure of the request body includes:
- the expression created in this step
- dynamic reference to a customer ID
{ "time": "", "label": "refer a friend points", "action": "points.upcharge", "client": { "id": {{event.params['body.customers[0].id']}} }, "params": { "points": {% expression %} f05e644c-7009-49d0-9208-18e9319af4a5 {% endexpression %}, "description": "referral_points" } }
-
In the Authorization section, select by API key as your method of authorization.
-
From the dropdown list below, select your API key.
-
Click Apply.
Add the End node
- On the Outgoing Integration node, click the plus button.
- From the dropdown list, select End.
- Save and activate the automation by clicking Save&Run.
Create an expression that calculates the number of points remaining for user 1
In this part of the process, you will create a formula that will calculate the number of points remaining for user 1. To do this, you will subtract the value of the points.upcharge event from the expression with the maximum number of points.
- Go to Analytics > Expressions > New expression.
- Enter the name of the expression.
- Leave the Expression option at default (Attribute).
- In the formula of the expression:
- Click Select.
- From the dropdown list, select Function > Profile.
- Click the unnamed node.
- At the bottom of the page, click Choose attribute.
- From the dropdown list, select the expression with the maximum number of points you created earlier.
- Click + button and from the dropdown list select Profile.
- Click the unnamed node.
- At the bottom of the page, click Choose attribute.
- From the dropdown list, select the points.upcharge attribute.
- Click the + button and change it to
-
. - In the upper-right corner, click Save.
- In the upper-right corner, click Publish.
Prepare a mobile push notification
Prepare a mobile push notification informing about the number of points awarded and points remaining for user 1, which will be used in the workflow created in the next steps of the process.
- Go to Communication > Mobile > Templates.
- Create your mobile push using the code editor or Drag&drop builder.
- If you use the code editor, you can use the code sample available below and adjust it as needed.
{
"notification": {
"title": "You have earned 500 points!",
"body": "Congratulations!!! You just earned 500 points for the registration of a new referred user!",
"sound": "default",
"priority":"high"
},
"data": {
"issuer": "Synerise",
"message-type": "static-content",
"content-type": "simple-push",
"content": {
"notification": {
"action": {
"type": "OPEN_APP"
}
}
},
"payload": {
"type": "points-earned",
"pointsReward": "{% expression %} f05e644c-7009-49d0-9208-18e9319af4a5 {% endexpression %}",
"title": "You have earned 500 points!",
"subtitle": "Thank you for being with us!",
"description": "You receive 500 points for the registration of a new user. You can earn {% expression %} 819f23f5-4f97-4039-b3ef-eb83130ac7c6 {% endexpression %} more points for the registration of additional users in the application."
}
}
}
Create a workflow that assigns the number of points awarded
In this part of the process, you will create a workflow that will assign the amount of times that points have been awarded to user 1. This information is stored in the referral_points_received attribute. Once the referral_points_received attribute is updated, user 1 will receive information about the number of points still to be earned, in the form of a mobile push.
Define the Profile Event node
Configure the condition that will trigger the workflow. This workflow will be triggered by the event generated in the previuos step - points.upcharge
.
- Add the Profile Event node. In the configuration of the node:
- From Choose event dropdown menu, choose
points.upcharge
event. - Click the + where button, from the Choose parameter dropdown menu, choose description.
- From the Choose operator dropdown, choose Contain.
- In the next field, type
referral_points
. - Confirm by clicking Apply.
Configure the Delay node
- Add the Delay node. In the node settings:
- In the Delay field, type
3
. - From the dropdown list, choose Second.
- In the Delay field, type
- Click Apply.
Define the Profile Filter node
In this step, as well as in further steps related to the Profile Filter node, you will check whether the user 1 referral_points_received attribute is equal to 0
, 1
or 2
, presenting the total number of times user 1 has received referral points.
Depending on the value of the attribute, it will be increased by one.
For example:
- if the attribute value is equal to
0
, it will be updated to1
; - if the attribute value is equal to
1
, it will be updated to2
; - if the attribute value is equal to
2
, it will be updated to3
.
- Add the Profile Filter node.
- In the settings of the node, click Choose filter and from the dropdown list, select referral_points_received.
- As the Operator, choose Equal.
- In the next field, enter
0
. - Click Apply.
- To the Matched path, add the Update Profile node.
Define the Update Profile node
In this part of the process you will update the referral_points_received attribute by increasing its value by a unit.
- Select the Update Profile node.
- From the left dropdown list, select Attributes > referral_points_received.
- From the right dropdown list, select Change.
- In the text field, type
1
. - Click Apply.
Define the Send Mobile Push node
Add Send Mobile Push node. This node will send a mobile push to user 1 with information about the number of points still available to earn from the referral campaign.
- Select the type of the mobile push notification as Simple Push.
- Select the push template, created in this step with the information about points gained.
- Skip the Additional parameters.
- Confirm the settings by clicking Apply.
Add the End node
Add the End node for this part of the flow.
To the Not Matched path from the Profile Filter node add Profile Filter node.
Define the Profile Filter node
In this step, you will check whether the attribute referral_points_received of user 1 is equal to 1
.
- Add the Profile Filter node after the first Profile Filter node.
- In the settings of the node, click Choose filter and from the dropdown list, select referral_points_received.
- As the Operator, choose Equal.
- In the next field, type
2
. - Click Apply.
- Define the Update Profile node for the Matched path.
For the Matched path:
- Define the Update Profile node in the same way as in the previous node, but updating the value of the referral_points_received attribute to
2
. - Add Send Mobile Push node with the same settings as in this step of the process.
- Add the End node.
For the Unmatched path of the Profile Filter node:
- Define Profile Filter node that will check whether the attribute referral_points_received of user 1 is equal to
2
.
For the Unmatched path, add the End node. - For the Matched path:
- Define Update Profile node updating the value of the referral_points_received attribute to
3
. - Add Send Mobile Push node.
- Add the End node.
- Define Update Profile node updating the value of the referral_points_received attribute to
- Save and activate the automation by clicking Save&Run.
Check the use case set up on the Synerise Demo workspace
You can check the configuration of all process steps directly in the Synerise Demo workspace:
- Aggregate that counts the sum of all user transactions
- Segment of users who meet the requirements of the referral program
- Expression that determines the number of points awarded for each referral
- Expression to determine the maximum number of points to be awarded
- Automation that generate a unique refferal code for user 1
- Automation that add referral points to the user 1
- Expression that calculate the number of points remaining for user 1
- Automation that assign the number of codes granted by user 1
If you don’t have access to the Synerise Demo workspace, please leave your contact details in this form, and our representative will contact you shortly.