How To Qualify Referrals Using A Javascript Snippet

One of the ways you can automatically qualify referrals when they convert is by installing a Javascript snippet on your website.

Referral Factory's javascript feature allows you to track when a referral converts on your website. You can then identify who the referring person is so that you can know when you need to issue them with a reward. 

Setting up Your JavaScript Snippet

Firstly, you will need to redirect invited users to your website or platform in order to for them to complete an action that will count as a successful referral – for example (completing a sign-up, creating an account, making a purchase, etc). You can do this in Step 2 for the person invited inside your campaign builder.

Once you have set up your redirect – you need to go to your Integrations tab in your campaign builder and select the Javascript option.

 

Qualification on “Thank You’ or “Success” page

You can use the script below to qualify each referral that successfully converts (on your own website or platform). Insert the script below on your ‘Thank You’ or ‘Success’ page, and it will notify us when a referred user has successfully converted – this user will then be marked as ‘qualified’ on the Referral Factory system.

Important: you must replace {code} with the code of the user that successfully converts – this {code} is passed to you as a GET parameter when the referred user is redirected to your website or platform. Here is an example of how we would pass this code:  https ://your-domain/redirect-path?code={code}

 

<script type="text/javascript" src="https://js.referral-factory.com/assets/js/qualification.js"></script> <script type="text/javascript"> if (window.RF) { window.RF.qualify({ code: "{code}" }); } </script> 

 

How To Store The Referred Users {Code}, And Pass It Back To Referral Factory When The User Qualifies (Or Converts)

 

Suggested method: javascript local storage. When our system redirects a referred user to your website or platform, we also send that user’s unique code through as a GET parameter. You will need to store this users’ code so that you can pass it back to Referral Factory when they convert.

You can save this code using javascript local storage and then call it again from your local storage when a user arrives at your “Thank You” or “Success” page.

You can also store this code in your own database, along with the referred users’ details – this method is often used when a referred user has to complete a set of actions in order to qualify, not just one.

Below we’ll show you how to use local storage to store the referred users code:

 

<script type="text/javascript"> let params = new URLSearchParams(window.location.search); // get params from current URL let code = params.get('code'); // get code from all params localStorage.setItem('rf_code', code); // set code to local storage as rf_code </script> 

 

Once a referred user has successfully converted, they should see a “Thank You” or “Success” page in your environment. On this page, you can get the referred users’ code by calling it from your local storage, in the case of our code example we use `rf_code`.

 

<script type="text/javascript"> let code = localStorage.getItem('rf_code'); // get code from local storage localStorage.removeItem('rf_code'); // remove code from local storage </script> 

 

Now that the user has converted, they will need to be marked as ‘qualified’ on the Referral Factory system. To do this you will need to qualify the referred user using their {code}, please see how to do that below.

 

<script type="text/javascript" src="https://js.referral-factory.com/assets/js/qualification.js"></script> <script type="text/javascript"> if (window.RF) { let code = localStorage.getItem('rf_code'); // get code from local storage localStorage.removeItem('rf_code'); // remove code from local storage window.RF.qualify({ code: code }); // qualify referral using `code` variable from local storage } </script>