I have created a email marketing tool in Codeigniter, I am able to track whether the email was opened and were the links clicked.
Onclick of links I am inserted the IP, the URL(which was clicked from the email newsletter) in cookies and the opened_datetime in the database .
The links would be only from our company website, I wrote a cron that will fire a ajax event on window unload event, that will pull the IP and URL from users cookies and update the record by matching IP and URl and the closed_datetime.
The issue is that the unload event does not get fired everytime.
Need a solution to it.