I have tried this: $_SERVER['HTTP_REFERER']
The challenge is it only gets the link that the person clicked on to reach the next page and not the actual URL of the previous page.
It does not matter if it can be spoofed. Its not mission critical. I just need to track a percentage of the results accurately.
$this->session->set_userdata('url11',"http://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]");
This it will work 100% use any variable in place url1
by which you can take it at place in application and write this thing in header of the view page in php tag.