I am trying to track visitors, who visits my website. I am using codeigniter for the development of the site. What i am interested in is to track the last visited page before they close the webpage. Is there anyways to do it?
What I have been thinking is to save their last visited page in session and then when they close save information in the database. What happens when user closes a browser or the website(tab in the browser) or when they click on the link (in the webpage) and is redirected to another website? does it send close connection request to the server?
What is the best way to keep track of it?
Also would like to mention the visitors are public and they cant login to the website. And also i am using google analytics but what to create a custom one for my website to get more accurate results.