Question

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.

Was it helpful?

Solution

Save/update a database entry on the current page they are loading. That way it doesn't even matter if their computer crashes it will still record the last page they were on. You could even restore them to the last place they were this way if they came back to the website later (if you needed this functionality).

OTHER TIPS

You can store the current page in the session for the user and when the session gets destroyed, you can get the last page visited by using session-set-save-handler.

Also, because HTTP is Stateless, you will never get a close connection callback.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top