Search code examples
phpweb

How to find my website URL comes from source(reference)?


i have a website ,i promoted it by sharing it's link on facebook and Google +.
i want to know whether the visitor come from by clicking the link i share on facebook or from Google + or from google search etc.
i don't have any official deal with both facebook and Google+ for promoting my website.

my question is! is it possible by any way ?


Solution

  • Since the http referer ($_SERVER['HTTP_REFERER']) won't be set consistently and there will be the support of rel=noreferrer attributes on anchors soon, this could be tricky.

    But since you are the one to share the links on social media, you could add a get parameter like:

    myFancyDomain.com?referrer=facebook
    

    This is the only consistent way I could imagine :)

    I guess this is a good quote (even it's kinda old):

    The "Referer" header entry is optional. You cannot rely on it being present. There is no cross-browser way to get the previous link because this depends on the user settings and proxy configuration (i.e. what the system administrators think they should allow you to see).

    You must find a way to live without this information.

    Source