Help guide: How to qualify referrals using Javascript

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}
Below are some frequently asked questions about how this works.
<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>
We hope this guide is helpful! If you have any technical difficulties during your setup, please schedule a call with our technical support team.