Referral program

Published April 18, 2023
Modules
Difficulty

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


Process


In this use case, you will go through the following steps:

  1. Create an aggregate that counts the sum of all user transactions.
  2. Create a segment of users who meet the requirements of the referral program.
  3. Create an expression that determines the number of points awarded for each referral.
  4. Create an expression to determine the maximum number of points to be awarded.
  5. Create a workflow that generates a unique referral code for the user 1.
  6. Create a workflow that adds referral points to user 1.
  7. Create an expression that calculates the number of points left.
  8. Prepare a mobile push notification.
  9. 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.

  1. Go to Analytics iconAnalytics > Aggregates > New aggregate.
  2. Enter the name of the aggregate.
  3. As the type of the aggregate, select Sum.
  4. From the Choose event dropdown list, select the transaction.charge event.
  5. As the event parameter, select $revenue.
  6. Set the period from which the aggregate will analyze results to Lifetime.
  7. Save the aggregate.
Aggregate settings
Aggregate settings

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.
  1. Go to Analytics icon Analytics > Segmentations v2 > New Segmentation.
  2. Enter the name of the segmentation.
  3. Choose Has property and find the aggregate counting the sum of all user transactions, created in the previous step.
  4. From the Choose operator dropdown, choose Number, and then select More or equal to.
  5. In the next field, enter the required transaction value, in our case it is 20.
  6. Choose Has property and find phoneVerified tag.
  7. From the Choose operator dropdown, choose Is true.
  8. Choose Performed action and find webhook.response event.
  9. Click the + where button, from the Choose parameter dropdown menu, choose name.
  10. From the Choose operator dropdown, choose Contain.
  11. In the next field, type add points to user 1.
    Note: add points to user 1 is the name of the Outgoing integration node used in this automation.
  12. Change the Performed action to Not performed by clicking the Performed word.
  13. Set the period from which the aggregate will analyze results to Lifetime.
  14. Save the aggregate.
The segmentation settings
The segmentation settings

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.

  1. Go to Analytics icon Analytics > Expressions > New expression.
  2. Enter the name of the expression.
  3. Leave the Expression option at default (Attribute).
  4. Click the Select button.
  5. Choose # Constant.
  6. Open the settings of Constant value by clicking 0.
  7. In the field below, type 500
  8. 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.

  1. Go to Analytics icon Analytics > Expressions > New expression.
  2. Enter the name of the expression.
  3. Leave the Expression option at default (Attribute).
  4. Click the Select button.
  5. Choose # Constant.
  6. Open the settings of Constant value by clicking 0.
  7. In the field below, type 1500
  8. 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.

  1. Go to Automation icon Automation > Workflows > New workflow.
  2. 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

  1. As the first node of the workflow, add Profile Event. In the configuration of the node:
    1. From Choose event dropdown menu, choose client.add event.
  2. Confirm by clicking Apply.

Define the Audience node

  1. Add the Audience node.
  2. In the configuration of the node, leave the value of the Run trigger option at default (one time).
  3. In Define audience, choose New Audience and click Define conditions.
    1. As the first condition, from Choose filter dropdown menu, choose anonymous_type attribute.
    2. From the Choose operator dropdown list, select Equal.
    3. Result: A text field appears.
    4. In the text field type NONE.
      Note: The anonymous_type attribute determines whether the profile is anonymous or recognized. By selecting the value NONE, you will include only recognized users.
    5. Click Choose filter and from the dropdown list, select my_referral_code.
    6. From the Choose operator dropdown list, select Boolean - Is true.
    7. Change the Profiles matching attribute option to Profiles not matching attribute by clicking the matching word.
    8. Click Apply.

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

  1. Add the Delay node. In the node settings:
    1. In the Delay field, type 3.
    2. From the dropdown list, choose Second.
  2. 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.

  1. Add the Profile Filter node.
  2. In the settings of the node, click Choose filter and from the dropdown list, select my_referral_code.
  3. As the Operator, choose Boolean - Is false.
  4. Click Apply.
  5. 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.

  1. Join the matched paths from the Profile filter node with the Update Profile node.

  2. From the left dropdown list, select Attributes > my_referral_code.

  3. From the right dropdown list, select Change.

  4. 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.

  5. Click Add field and from the dropdown list, select Attributes > referral_points_received

  6. From the right dropdown list, select Change.

  7. In the text field, enter 0.

  8. Click Apply.

    The configuration of the Update Profile node
    The configuration of the Update Profile node
  9. Select the End node.

Final configuration of the workflow
Final configuration of the workflow

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).
  1. Go to Automation icon Automation > Workflows > New workflow.
  2. 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

  1. As the first node of the workflow, add Profile Event. In the configuration of the node:
    1. From Choose event dropdown menu, choose transaction.charge event.
  2. Confirm by clicking Apply.

Define the Profile Event node

  1. Add Profile Event. In the configuration of the node:
    1. From Choose event dropdown menu, choose client.addTag event.
    2. Click the + where button, from the Choose parameter dropdown menu, choose name.
    3. From the Choose operator dropdown, choose Equal.
    4. 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.
  2. 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

  1. Add the Delay node. In the node settings:
    1. In the Delay field, type 10.
    2. From the dropdown list, choose Second.
  2. 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.

  1. Add the Profile Filter node.
  2. In the settings of the node click Choose filter and from the dropdown list, select the segmentation you already created in this step.
  3. As the Operator, choose Boolean - Is true.
  4. 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.

  1. Add the Outgoing Integration node for the matching path.
  2. In the Definition section, choose the Custom webhook tab.
  3. In the Webhook name field, enter a name for the webhook. In this case find user 1.
  4. 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.
  5. In the Authorization section, select by API key as your method of authorization.
  6. From the dropdown list below, select your API key.
  7. 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).
  1. As the next node, add Event Filter. In the configuration of the node:
    1. In the Check field, leave the default value without limits.
    2. In the Define conditions field, from the Choose event dropdown menu, choose webhook.response event.
    3. Click the + where button, from the Choose parameter dropdown menu, choose name.
    4. From the Choose operator dropdown, choose Equal.
    5. In the next field, type find user 1.
    6. 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.
    7. From the Choose operator dropdown, choose Less or equal.
    8. In the next field, type 3
  2. 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.

  1. Add the Outgoing Integration node for the matching path.

  2. In Definition section, choose the Custom webhook tab.

  3. In the Webhook name, field enter a name for the webhook. In this case add points to user 1.

  4. Select the POST method.

  5. In the URL of the endpoint, enter https://api.synerise.com/v4/events/custom.

  6. In the headers section:

    • set content-type value to application/json
    • setaccept value to application/json
    • define api-version to 4.4
  7. 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"
        }
      }
              
  8. In the Authorization section, select by API key as your method of authorization.

  9. From the dropdown list below, select your API key.

  10. Click Apply.

Add the End node

  1. On the Outgoing Integration node, click the plus button.
  2. From the dropdown list, select End.
  3. Save and activate the automation by clicking Save&Run.
Final configuration of the workflow
Final configuration of the workflow

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.

  1. Go to Analytics icon Analytics > Expressions > New expression.
  2. Enter the name of the expression.
  3. Leave the Expression option at default (Attribute).
  4. In the formula of the expression:
    1. Click Select.
    2. From the dropdown list, select Function > Profile.
    3. Click the unnamed node.
    4. At the bottom of the page, click Choose attribute.
    5. From the dropdown list, select the expression with the maximum number of points you created earlier.
    6. Click + button and from the dropdown list select Profile.
    7. Click the unnamed node.
    8. At the bottom of the page, click Choose attribute.
    9. From the dropdown list, select the points.upcharge attribute.
    10. Click the + button and change it to -.
    11. In the upper-right corner, click Save.
    12. In the upper-right corner, click Publish.
Final configuration of the expression
Final configuration of the expression

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.

  1. Go to Communication > Mobile > Templates.
  2. Create your mobile push using the code editor or Drag&drop builder.
  3. If you use the code editor, you can use the code sample available below and adjust it as needed.
Note: Remember to change the expression IDs in this code, as they refer to the expressions created in this use case.
Check the Jinjava code

{
	"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.

  1. Add the Profile Event node. In the configuration of the node:
  2. From Choose event dropdown menu, choose points.upcharge event.
  3. Click the + where button, from the Choose parameter dropdown menu, choose description.
  4. From the Choose operator dropdown, choose Contain.
  5. In the next field, type referral_points.
  6. Confirm by clicking Apply.

Configure the Delay node

  1. Add the Delay node. In the node settings:
    1. In the Delay field, type 3.
    2. From the dropdown list, choose Second.
  2. 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 to 1;
  • if the attribute value is equal to 1, it will be updated to 2;
  • if the attribute value is equal to 2, it will be updated to 3.
  1. Add the Profile Filter node.
  2. In the settings of the node, click Choose filter and from the dropdown list, select referral_points_received.
  3. As the Operator, choose Equal.
  4. In the next field, enter 0.
  5. Click Apply.
  6. 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.

  1. Select the Update Profile node.
  2. From the left dropdown list, select Attributes > referral_points_received.
  3. From the right dropdown list, select Change.
  4. In the text field, type 1.
  5. 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.

  1. Select the type of the mobile push notification as Simple Push.
  2. Select the push template, created in this step with the information about points gained.
  3. Skip the Additional parameters.
  4. 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.

  1. Add the Profile Filter node after the first Profile Filter node.
  2. In the settings of the node, click Choose filter and from the dropdown list, select referral_points_received.
  3. As the Operator, choose Equal.
  4. In the next field, type 2.
  5. Click Apply.
  6. Define the Update profile node for the Matched path.

For the Matched path:

  1. 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.
  2. Add Send Mobile Push node with the same settings as in this step of the process.
  3. Add the End node.

For the Unmatched path of the Profile Filter node:

  1. 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.
  2. For the Matched path:
    1. Define Update Profile node updating the value of the referral_points_received attribute to 3.
    2. Add Send Mobile Push node.
    3. Add the End node.
  3. Save and activate the automation by clicking Save&Run.
Final configuration of the workflow
Final configuration of the workflow

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:

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.

Read more


😕

We are sorry to hear that

Thank you for helping improve out documentation. If you need help or have any questions, please consider contacting support.

😉

Awesome!

Thank you for helping improve out documentation. If you need help or have any questions, please consider contacting support.

Close modal icon Placeholder alt for modal to satisfy link checker