Find out the referers to your website

First published on Sep 08, 2014 - Last updated on Sep 08, 2014

Find out who referred the visitors to your website

Since Google Analytics does not show what did the visitors search in order to arrive to my website, I decided to look for a simple script to record who the referers are.
I initially considered to have an email sent for every visitor (since I only get about 15...20 visitors per day), but I found out the mail sending slows down the website significantly, so I removed the mail sending function.
In the end I added to the footer section the following php script:


    $ref = $_SERVER['HTTP_REFERER'] . "\r\n";
    $file = 'referers.txt';
    $current = file_get_contents($file);
    $current .= $ref;
    file_put_contents($file, $current);

You can view the referers to any of the pages in here:

Unfortunately, it proves that all the organic search results appear blank in the list. This is because Google encrypts all data (they use https).
But when there are problems, there are (potential) solutions. At least we can find what the landing page was, this would give us a better idea what brought the visitors to our website.


This template downloaded form free website templates