Log the page from where the clickout if coming using PHP
<p>Currently I have a system within PHP where I track the click outs of a website. For these clicks I track various points of information which are available in the url and/or server (like IP address, date &amp; time).</p>

<p>An example url is: /out/123/2/ where the 123 is the supplier ID and /2 tells me if the click out origin is coming from a newsletter (or other external, not my website related, page).</p>

<p>I want to also track the page from where the click out is coming from. I currently use  $_SERVER['HTTP_REFERER'] to get the referrer page of the visitor, but currently this is not always filled when the visitor clicks the link. Some instances are blank/empty.</p>

<p>I’m looking for a solution that captures are ‘last’ pages when the visitor clicks on the click out, the above solution with the HTTP_REFERER is not working 100%. Alternative options I have been thinking about are:</p>

<ul>
<li>Use Sessions – Store the last page in the session and read from it when processing the click out.</li>
<li>Use Cookies – same as sessions, but now with cookies</li>
</ul>

<p>Both will work when the visitor is on the website, but when an visitor is not on the website I will get a blank outcome. This will not allow me to track the visitor where it came from, to improve the functionality.</p>

<p>What is the best practice to track all ‘last’ pages from the visitors on the website when they click the ‘click out’ url?</p>
