Currently, I am using this:
<A href="/?id=page_name2&referrer=<?php echo $_GET['id']; ?>">Page Name 2</A>
Which displays the URL like this:
www.domain.com/?id=page_name2&referrer=page_name
I want to store the referring data to a TXT file, which will be in a folder on a server. I do not want to use Google Analytics nor any SQL.
Hmm, you can build a referrers.json file like this:
{
"page_name": 1,
"page_name_2": 4,
"page_name_etc": 9
}
Where 1, 4 and 9 are the times those pages were used as referrers.
Look at this code:
$file = 'referrers.json';
$arr = (is_file($file))
? json_decode(file_get_contents($file), true)
: [];
$referrerId = 'some_page';
if (array_key_exists($referrerId, $arr)) {
$arr[$referrerId]++;
} else {
$arr[$referrerId] = 1;
}
file_put_contents($file, json_encode($arr));