Level up your referral & loyalty program with integrated data & automation

This recipe teaches you how to easily launch and optimize a referral and loyalty program using Segment and Friendbuy. The web and cloud mode destination integrations send information about your customers and their actions to Friendbuy to power your referral and loyalty programs.


Made by Friendbuy

What do you need?

  • A website to send events

  • A FriendBuy workspace

  • A Segment Workspace

This recipe will show you how to seamlessly launch a best-in-class referral and loyalty program using Friendbuy and Segment. With customer actions and data flowing between both platforms, you’ll be able to acquire high value new customers through referral and reward your most loyal customers and increase customer lifetime value.

“Out of all of our organic channels referrals drive the most growth, so Friendbuy has been really important. We rely heavily on Friendbuy to scale our organic mix.”  - Rachel Smith, CRM & Analytics Manager @Nuuly

Why it matters

  • A referral program should be your best channel for acquiring new customers

  • High-growth brands can acquire 5 - 15% of new customers through a referral program

  • Referred friends have a 3 - 4x higher lifetime value compared to other channels 

  • A loyalty program is the most effective way increase customer lifetime value

Step 1: Set up Friendbuy as a destination in Segment

Before you start, you must have Segment’s Analytics.js 2.0 installed on your site. See Segment’s documentation for instructions.

  1. Find your Friendbuy Merchant ID, a unique UUID that Friendbuy uses to identify your account. Log in to your Friendbuy account and visit the Developer Center > Friendbuy Code page to locate your Merchant ID.

  2. From the Segment web app, click Catalog, then click Destinations.

  3. Filter the destinations on Friendbuy in the Catalog and select Friendbuy Web Device Mode (Actions). Click Configure Friendbuy Web Device Mode (Actions) to configure the Friendbuy destination, and choose which of your sources to connect the destination to.

  4. Give the destination a name, and fill in the settings manually.

  5. On the Basic Settings page enter your Merchant ID value from step one, and click Save Changes.

Step 2: Map your events

Next, select the Mappings tab in Segment. A number of pre-built mappings are configured for you that map standard events defined in the Segment Spec to their equivalent Friendbuy events. You can disable events that you don’t use or edit the pre-built field mappings.

After you configure the destination, enable it from the Settings tab. As noted above, the Friendbuy JavaScript will not be loaded unless at least one Mapping is enabled. Below is a look at some of the available out-of-the-box mappings Friendbuy has configured for you. 


You can also add new mappings to support custom events that are important for your referral and loyalty program. For more information on event mapping, please read the following help documentation

Here are some additional details about each mapped event: 

  • Track Customer: Converts Segment analytics.identify calls to Friendbuy track customer calls. Use this to add your customer ID and other customer data to the information that Friendbuy has about the customer.

  • Track Purchase: Converts Segment analytics.track('Order Completed') calls to Friendbuy track purchase calls. Use this to send purchase data to Friendbuy so Friendbuy can trigger rewards for your referral and loyalty program.

  • Track Sign-Up: Converts Segment analytics.track('Signed Up') calls to Friendbuy track sign_up calls. Use this to track sign-up actions as part of your referral funnel and to potentially reward customers for account creation or other sign-up actions in a loyalty program.

  • Track Page: Converts Segment calls to Friendbuy track page calls. Use this to enable the display of Friendbuy widgets based on page name.

  • Track Custom Event: Converts an arbitrary Segment analytics.track call with an event name and properties of your choosing to a Friendbuy track custom event call.  Use this to track custom events as part of your loyalty program to reward customers for events that are important to your business (e.g. mobile app download, etc).

Once your mappings are set up, you can then configure and test your event triggers through the below steps. 

  • Set up event trigger: Choose the event trigger, which is the event type (such as Identify) or event name (such as Order Completed) for events that should be sent to Friendbuy.

  • Test event trigger: Find a sample event in your Segment event stream that matches the trigger you defined in step one.

  • Configure action fields: Define how the fields in the Segment event are mapped to fields in the Friendbuy track event.

Review mappings: Verify that the fields in the sample event are mapped correctly.

Step 3: Set up a referral campaign

Congratulations! You’ve now connected Friendbuy and Segment, and are ready to start driving referrals. 

First, go to and log in to your account. From there, select Referral in the left-hand sidebar.  Then click the blue Create a Campaign button on the top right-hand corner of the screen.


Then, it's time to set up the basics for your campaign! Enter the name of your new campaign, a campaign description (optional), and if you'd like the campaign to be evergreen or time limited. Once done, click the blue next step button!


The next step is to choose an Advocate Reward. This will be the reward that goes to the referrers for successfully referring their friends! Using the drop-down menu, select the method in which you will be rewarding your Advocates. For this example, we'll be going through the flow of setting up a coupon code based reward.


Once coupon code is selected, you will need to select a code bank to pull the coupons from, as well as indicate when the reward should be triggered. The above example shows “Friend makes a purchase” as the rewardable event. Remember, these can be customized to the event’s that are most important to your business.

After the reward settings have been configured, we'll be moving on to the reward rules. Here, we can specify if we would like the Referred Friends to meet a minimum purchase amount in order for a reward to be sent to the Advocate. This is optional and only applicable if your reward will be triggered by a Referred Friend making a purchase.

We also can specify if we want to require the Referred Friend to be a new customer in order for the Advocate to be rewarded.

We've now finished setting up the Advocate Reward settings, and it's time to move on to the Friend Incentive! Much like our Advocate Reward, this will be a coupon code for this example. This Friend Incentive will be the offer that the Friend receives after being referred to your website.


Once you’ve selected your coupon code Friend Incentive option, you’ll be given a few additional requirements in order to configure the full Friend Incentive. First, you’ll need to set up a code bank to pull Friend Incentives from, as well as set up How the Friend Incentive should be triggered.

Once your Incentive Settings have been configured, we'll be moving on to setting up your incentive rules! Here, we'll be selecting if the Referred Friend needs to be a referred customer in order to receive an Incentive, as well as if the Friend needs to be a new customer in order to receive an Incentive.

After setting up your incentive rules, it is time to configure a Friend Destination/Redirect URL! This is a URL that a Referred Friend will be taken to after clicking through a referral link.This will usually be a URL where referred Friends will be presented with an incentive to purchase , or a URL where customers will be directed to your desired purchase funnel.

It's time to review your overall configuration of your new campaign! On this step, you'll be able to see the Reward Type, Code Bank, and Reward Trigger that you've configured for both your Advocate Rewards and your Friend Incentives. If all looks good, you can press the blue Finish button to officially create your new campaign!


Congratulations! You have now set up the foundations of your new campaign.You'll need to create and design the customer facing emails and referral widgets before launching your campaign.

Step 4: Set up loyalty events

Your loyalty and referral program should complement one another, but be optimized independently to drive the best results. So now that you’ve set up a referral campaign, let’s look at how you can set up custom loyalty program events to reward customers for taking the actions that are most important to your business. 

First, go to and log in to your account. From there, select Loyalty in the left-hand sidebar. Then use the centered navigation bar and click Earning Events.


Now it’s time to set up an event that you’d like to reward customers for taking. Some of the most common actions are: 

  • Making a purchase

  • Referring a friend

  • Signing up for your loyalty program

  • Subscribing to marketing communication (SMS and email) 

Once you know the event you’d like to set up, click the  + Add Earning Event button on the top right (see screenshot above). Then choose either a pre-set event from the options displayed, or choose a custom event, and click Add Event.  


For this example, we’ll set up the event Make a Purchase. In the next screen, pick which reward type you’d like to reward your customer with from the dropdown Reward with. You can choose points, points for each 1 USD spent, coupon code, gift card, or a configure a custom reward. 


For points, add a total number of points they should receive for taking an action. Then choose if you’d like an email to be sent to notify the customer of their reward. 


Note: Friendbuy has an internal email center where you can create customized email templates that work with your referral and loyalty programs. 

Once you’ve picked your reward and email, select Save Changes to keep a draft, or select Save & Activate to have your event go live immediately. 

Don’t forget to map your Friendbuy earning events to Segment, so you’re able to easily keep track of all the event data.. 

Step 5: Optimize your referral and loyalty programs

The Friendbuy and Segment integration was designed to help you not only launch your referral and loyalty program quickly, but ensure you’re consistently optimizing it with integrated data. 

You can now send the following data from Friendbuy to Segment, to ensure your messaging aligns with each customer's journey:

  • Customer data 

  • Sign Ups 

  • Purchases 

  • Custom events 

By the end of 2022, you’ll also be able to send referral event data and loyalty event data from Friendbuy to Segment in real time. For your referral program, that means you can send share events, as well as clicks, purchases, rewards earned and incentives distributed. For your loyalty program, you can send events such as when someone joined the program, purchases generated, and rewards earned.

Wrapping up

Here’s what we’ve accomplished together in this recipe: 

  • Set up Friendbuy as a destination in Segment 

  • Mapped custom events from Segment to Friendbuy 

  • Set up a referral campaign 

  • Set up loyalty events that are important to your business 

  • Learned which data points can help optimize your referral and loyalty programs with Friendbuy and Segment 

Getting started is easy

Start connecting your data with Segment.