Skip to main content
All CollectionsHow to monetize - Conversion Campaigns
Setting up a referral program for existing customers (Viral Loops widgets + API)
Setting up a referral program for existing customers (Viral Loops widgets + API)
support_viral_loops avatar
Written by support_viral_loops
Updated over a week ago


This is an overview of how a business with existing clients can set up a referral program to reward already-paying customers for referring their friends.

If you’ve reached this page, you probably know the benefits of having a referral marketing campaign, but as a refresher, here are the main benefits we have identified from almost 5,000 campaigns built with Viral Loops:

  • Providing incentives for referrals increases the likelihood that your customers invite their friends.

  • Growing through referral marketing reduces your Customer Acquisition Cost (CAC) as you do not pay per click or conversion — you build your own channel.

  • Prospecting customers are more likely to convert if they get a recommendation from a friend.

Now, imagine you are the CEO or CMO of a software company.

Your product is a “web app”, and you already have about 1,000 paying customers.

Your customers are happy and loyal. You notice that some new customers come through recommendations of existing customers — costing you no money in ads.

Now, consider creating a long-term referral program for every paying customer of yours so they can be more motivated to invite their friends — the goal is to get more customer referrals.

We developed Viral Loops precisely for that purpose.

To create a Viral Loops referral program for your brand, understanding the flow you need to build is essential.

A referral campaign is not just a form where people copy a referral link or code — it is a complete viral loop looking like this:

This article provides the steps needed to design and deploy this complete flow.

1. What to consider before setting up

There are some essential aspects of your referral marketing strategy for your campaign before you start the technical set-up. Viral Loops cannot help you with these as they depend on your goals and business.

1.1 Decide on who gets a referral link.

Key question:

Will every user get a referral link automatically (auto opt-in), or will they have to join the referral program themselves (manual opt-in)?

For our example, because you want to make the referral process fast and easy, you want all users to have a referral link they can copy from their app dashboard. You prefer auto opt-in.

1.2 Align your business objectives with successful referrals

Key question:

What results do you expect from the referral program? In other words, what will trigger a successful referral? Free trial users? Paying users? Email subscribers?

For our example, you want to get more paying users out of this campaign. You want a successful referral triggered when the invitee becomes a paying customer.

1.3 Decide on who gets the rewards

Key question:

Do you want to reward the referrer and the invitee? Only the referrer? Only the invitee?

For our example, you want to reward only the refer for every referral they make.

1.4 Pick the rewards/incentives

Key question:

What rewards/incentives will you offer your customers for referring friends?

You want your rewards to give more product value to your customers, so you want to offer subscription discounts for every referral.

2. Setting up a referral program with Viral Loops

2.1 Pick a Viral Loops template

Because you want to count successful referrals when invitees pay for your product (a custom conversion), you have two template options:

  1. Milestone Referral: A referral program with referral milestones providing better rewards with more referrals.

  2. Altruistic Referral: A two-sided referral program offering an incentive to the invitee and the referrer — the rewards are the same regardless of how many referrals.

For our example, you think the milestone flow will be more effective for your type of customer, so you pick the Milestone Template.

2.2 Set your campaign options

2.2.1 Basic info

Set your campaign name for internal use only and specify the URL that the referral link will take people to.

2.2.2 Rewards and milestones

Here, you “tell” Viral Loops what Milestones you want to offer and when each milestone is achieved.

You should send a confirmation email when every milestone is reached. You can do that through Viral Loops or integrate your email platform with Viral Loops and send it from there.

2.2.3 Referral widgets

These are the elements your customers will interact with to copy their referral link, and check their progress.

For the form widget, you should ignore the Joining State since you will auto-opt-in your customers to the referral program.

It is highly recommended you customise the widgets so they appear like a core part of your brand in terms of fonts and colours.

(If you want fully custom designs built inside your app, you can skip this section completely and refer to the API and SDK documentation to find out how you can get all the Viral Loops data to populate your custom elements)

2.2.4 Integrations

Viral Loops integrates with various tools in three ways:

  1. Integrations to receive data into your Viral Loops campaign

  2. Integrations to send data from your VL campaign

  3. Integrations to send and receive from and to your campaign

If you want to exchange data with any of these, select them and follow the instructions inside.

2.3 Adding / Integrating the campaign to your business

Now that the campaign properties are ready, it’s time to make it real.

In context, we now want to:

  1. Give the pre-existing customers a referral link

  2. Create a way to generate referral links for new customers who join with and without a referral link.

  3. Create a page where customers can get their referral and check their progress.

  4. Trigger a successful referral when someone becomes a customer through a referral link.

2.3.1 Participation of existing users

This step concerns how your existing users get their referral code. As decided in the beginning of the campaign:

You want all existing users to get a referral code. Instead of asking them to opt-in using the joining state widget.

To do that, you have two options:

  1. CSV Import your users to Viral Loops

  2. Participate all existing users though the backend API

Since you want to avoid bothering developers with marketing stuff, you prefer CSV Import.

Now, Viral Loops has given all these people a unique referral link—but this is still inside Viral Loops only.

2.3.2 Participation of new customers

A lot of customers will come through customer referrals, but quite a few will also come on their own without a referral.

Since both types will be customers who might refer friends, you want them to automatically get a referral link, too — to become referral program participants.

To do that, you have two options:

  1. Use the Zapier integration

  2. Use the API

In this article, we assume you do not have a Zapier account — let’s do it with the API.

To register new participants to the campaign, you need to make a POST request to [] with the necessary information. View complete documentation here.

Make sure you create a condition that adds a new participant’s referrer if they have one.

Alternatively, using the Viral Loops SDK, you can also do it from the front end. This is useful to parse the referrer’s code from a URL parameter or the localStorage.

2.3.3 Widgets — Set up how your users interact with the referral program

The information you want users to see are:

  1. Their referral link

  2. The number of referrals they’ve made

  3. The rewards they have earned

We recommend adding all elements containing this information to a dedicated page — a referral dashboard.

A dashboard with the Viral Loops widget can look like this:

Alternatively, if you spend time making custom designs and manually parsing data, a fully custom referral dashboard can look like anything, for example:

For this example, we’ll only use the Viral Loops widgets — preferable if you do not have the resources to do fully custom works.

Let’s say you want the referral dashboard to live on the Profile page inside your app.

Go to your page and add the Viral Loops snippet in the <head>

<script type="text/javascript" id="viral-loops-loader" data-campaign-id="KhmVIpGpMCVRTazAIAopM7SQUzM" src=""></script>

Because you automatically give everyone a referral link, you do not use or want the joining state of the Viral Loops widget. Everyone is a participant, so they should only see the sharing state.

Because of this, you now need to write some code to display only the sharing state:

  1. Get the user email in the front end of your app (For example, in window.localStorage)

  2. Add the form widget (which contains the sharing state) where you want it to be.

<form-widget ucid='KhmVIpGpMCVRTazAIAopM7SQUzM'></form-widget>

Then, make a campaign.identify() call when the page loads and parse in the user email. This will “tell” the form widget to show only the sharing state with the referral link of that person.

2.3.5 Conversion — closing the viral loop

Now, it’s time to define what makes a successful referral. In other words, what actions will close the referral loop.

As you initially decided, you only want to measure paying customers who came through referrals.

To do that, you need to trigger a conversion using the API.

To set this up, you need to make a POST request with all the invitee information to [] when the invitee makes a purchase. View the complete documentation here.

3. Rewarding and campaign management

3.1 Find who deserves a reward

If everything has been set up correctly, you can see which participant deserves a reward in your Viral Loops dashboard.

3.2 Rewarding participants

It is entirely up to you to reward participants. Viral Loops does not deliver gifts or directly communicate with your business processes to distribute your rewards.

You have two options to reward your participants:

  1. Manually reward your participants in any way

  2. Create a Zapier automation to give the rewards through another tool

Similar to previous steps, we assume you don’t have a Zapier account, so you prefer the manual way.

Usually, our customers create a small routine where, once a week or so, they check their Viral Loops dashboard and export the participants that deserve a reward.

Then they go to the corresponding system, like Stripe, and give them the reward, like a discount.

3.3 Preventing campaign fraud

Viral Loops automatically identifies which participants might be exploiting your campaign and creates a list ordered by Fraud Risk.

It is entirely up to you to evaluate this fraud risk and decide if you should ban that participant. Please check the referral they’ve made yourself for potential fame customers.

Did this answer your question?