Last Page Tracking

I am trying to track visitors who visit my site. I use codeigniter to develop a site. I'm interested in tracking the last page visited until the webpage closes. Is there any way to do this?

What I was thinking about was to save my last page visited in the session, and then when they close the saving of information in the database. What happens when a user closes a browser or website (tab in a browser) or when he clicks on a link (on a web page) and redirects to another website? Does it send a request for a closed connection to the server?

What is the best way to track this?

I would also like to note that visitors are publicly available, and they cannot enter the site. I also use Google Analytics, but what to create custom for my site to get more accurate results.

+4
source share
2 answers

Save / update the database entry on the current page you are loading. Thus, it does not even matter if their computer crashes, it will still save the last page on which they were. You can even restore them to the last place where they were that way if they return to the site later (if you need this functionality).

+4
source

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

Also, since HTTP is idle, you will never receive a callback with a closed connection.

0
source

All Articles