How to find out from which website/source your application has been called

This is the code that you need to place in your default index page or any page for getting the referrer and redirect the user to "some_url". Replace the "some_url" with your own website link to redirect the user if the user is coming from Facebook or example domain names.

<script>
function getTheReferrer() {
    var referrer = document.referrer;
    if (referrer.indexOf('www.facebook.com') !== -1 || referrer.indexOf('www.example.com') !== -1) {
        window.location.href = 'some_url';
    }
}
window.onload = function() {
    getTheReferrer();
}
</script>

If you want to try this here then follow the below steps -
  1. Go to Inspect Mode by clicking the button f12 on your keyboard or pressing CTRL+SHIFT+I key combination.
  2. Then inspect by clicking on the arrow symbol in the inspect window.
  3. Click on the "here" link on the bottom.
  4. Change the href attribute of the below anchor (<a>) tag to the url ("https://www.example.com") where you want the user to redirect.
  5. After changing the url to your desired one, click on that hyperlink.
  6. Now, you will be able to redirect to the URL you modified in the anchor (<a>) tag.


The below content is STRICTLY for Developers
Test the document referrer by changing the URL of this link in "Inspect Mode" and then by clicking here

How to find out from which website/source your application has been called

This is the code that you need to place in your default index page or any page for getting the referrer and redirect the user to "some...