How to qualify your referred users, using JavaScript

The ability to qualify your referred users when they convert will make managing your referral campaign easier because it allows you to see in real-time how many referrals you have, and how many of those have converted/qualified.

Xnip2022-10-23_18-25-21
 
Important: you must have the redirect option toggled on in Step 3 if you want to use Javascript to qualify the person invited when they convert. This is because when the user is redirected to your website after step 3, we pass their CODE in the URL that they are redirected to. You will need this code to insert into the Javascript snippet you fire back to Referral Factory when the user converts. 
 
This is how to setup your campaign on step 3 ๐Ÿ‘‡
 
Xnip2022-11-01_17-52-27
 
This is how to setup your campaign on step 4 ๐Ÿ‘‡
 
Xnip2022-11-01_17-58-26
 
If you follow the steps above, your campaign will now be setup to redirect the person invited to your website ๐Ÿ‘
 
Once the user is redirected they will be sent to the 'Redirect URL' you setup on step 4. Referral Factory will also pass the users data into the URL as a GET parameter.  
 
So if you set your redirect URL as this: 
https://www.yourwebsite.com/start-free-trial
The referred user will be redirected to this URL: 
https://www.yourwebsite.com/start-free-trial?first_name={firstname}&email={email}&code={code}

Your developer can then see the referred users first name, email, and code - which they can save into your system to pre-pouplate any forms the user needs to fill in to complete their registration / sign up / purchase on your system. 

You can store the users code either directly into your database (recommended) or into the users local browser storage.  
 
Once the referred users converts, all you need to do is fire the below snippet as an event in your 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>
 
Once this JS code is fired, the referred user will then become qualified ๐Ÿ‘
 
Xnip2022-11-01_18-15-26
 
 
Below are some additional resources provided by our developers if want to use the 'local storage' option mentioned above, to store the users code. 
 
This is 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 user's 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>

We hope this guide is helpful!
 
If you have any technical difficulties during your setup, please schedule a call with our technical support team.