You can easily register your users into your referral campaign through your existing sign-up form. Once they are registered, you can show them their referral dashboard with their unique referral link and sharing options. You can either redirect them to a Thank You page with referral widget on it or go with your existing flow and give them a link to their 'refer-a-friend' or 'referral-dashboard' page.

Here is what you will learn in this tutorial.

  1. Connect your website to your iRefer account. 
  2. Specific campaign settings required.
  3. Connect your sign-up form to your referral campaign.
  4. Embedding the sharing widget into your "Thank You" page.
  5. Testing your campaign

Here is the flow of a SaaS referral program and where you will need to integrate our code outlined in the steps below.

1. Connect your website to your iRefer account.

Step 1
Navigate to your campaign by clicking on the "Edit" button in your Dashboard.

In the left navigation, click on the "Installation" button, then "Custom website" as shown in this screenshot.

Copy the line of code as shown in "Step 1" of this screenshot. 

Step 2
Install this script on your website site by pasting in before the closing </body> tag of the page.

Step 3
Refresh the home page of your website. Then refresh this page. If installed correctly, you should see a green check here.

2.Specific campaign settings required

There are some specific campaign settings you need to set.
On the "Initial setup" page choose the "Embedded" form style and change the shortcode from <div id="shortcode"></div> to <div id="sharewidget"></div>

Click on "Advanced Options" and choose "Yes" for "Automagically sign-up new participants?"

Click Save and Continue.

For this type of campaign, you can skip the following page - "Sign-up form"  as you will be using your form.

3. Connect your sign-up form to your referral campaign

You need to pass the user's email address into your referral campaign. There are two ways you can achieve this. Either option would work fine.

Option 1 - Using Cookie - You need to write the user email address to vsu_ref_email cookie for your website. 

Learn how to integrate your own form with iRefer by embedding a simple script in your website.

Here is a sample JavaScript code for adding the user email address to vsu_ref_email cookie. You need to add this code to your form submit event (change "your-email") to email field name on your form.

var user_email = document.getElementsByName("your-email")[0].value;
var domain_name = window.location.hostname;
if (domain_name.startsWith("www.")){
    domain_name = domain_name.substring(4);

var days = 365;
var date = new Date();
date.setTime(date.getTime() + (days*24*60*60*1000));
var expires = "; expires=" + date.toUTCString();

document.cookie = "vsu_ref_email=" + user_email + expires + "; domain=." + domain_name + "; path=/";

Option 2 - Using Querystring
- You need to pass the user email address to vsu_ref_email url querystring parameter in the URL. Below is example JavaScript code you need to add to your sign-up form.

You should change "your-email" to match the ID used in your sign-up forms email field.  

"" could be the URL the user is redirected to after submitting your form, if you are sending them to a thank you page.

var user_email = document.getElementsByName("your-email")[0].value;
user_email = encodeURIComponent(user_email);
location = '' + user_email ;

4. Embedding the sharing widget into the "Thank You" page, after the user has submitted your form.

Now we need to insert the shortcode below into the HTML part of the Thank You page you will redirect the user to after they have submitted your form. 

<div id="sharewidget"></div>

After submitting your form, they will then see this widget embedded into your "Thank You" page. You should place content around this widget to explain what rewards they will get for referring friends.

5. Testing your campaign

Now let's test your campaign to make sure everything is correctly setup.

When someone signs up through your form and submits, their email address should have been passed in the URL as a query string.

They are then redirected to your "Thank You" page, where they will see their unique referral link which they can start sharing right away. A Welcome email will also have been sent to their inbox.


Did this answer your question?