I tracked emails for many years using the lighthouse image, and for those clients that let you upload images, it worked just fine to keep track of how many people have opened emails.
I came across the service "DidTheyReadIt", which shows how long the client really reads the letter, I tested it with my free service, and in fact it is pretty close to the time when I opened the letter.
I’m very curious how they achieve the ability to track this, I’m sure that regardless of the solution chosen, it will put a lot of load on the server / database and that many of the community will answer “Stop, No and Dont”, but I want to explore this and try, even if it’s enough to run a test on the server and say "no hell."
I did some search queries and found this article, which has a basic solution http://www.re-cycledair.com/tracking-email-open-time-with-php
I did a test using sleep () on the beacon image page:
<?php set_time_limit(300); //1000 seconds ignore_user_abort(false); $hostname_api = "*"; $database_api = "*"; $username_api = "*"; $password_api = "*"; $api = mysql_pconnect($hostname_api, $username_api, $password_api) or trigger_error(mysql_error(),E_USER_ERROR); mysql_select_db($database_api, $api); $fileName = "logo.png"; $InsertSQL = "INSERT INTO tracker (FileName,Time_Start,Time_End) VALUES ('$fileName',Now(),Now()+1)"; mysql_select_db($database_api, $api); $Result1 = mysql_query($InsertSQL, $api) or die(mysql_error()); $TRID = mysql_insert_id(); //Open the file, and send to user. $fp = fopen($fileName, "r"); header("Content-type: image/png"); header('Content-Length: ' . filesize($fileName)); readfile($fileName); set_time_limit(60); $start = time(); for ($i = 0; $i < 59; ++$i) { // Update Read Time $UpdateSQL = "UPDATE tracker SET Time_End = Now() WHERE TRID = '$TRID'"; mysql_select_db($database_api, $api); $Result1 = mysql_query($UpdateSQL, $api) or die(mysql_error()); time_sleep_until($start + $i + 1); } ?>
The problem with the above code (except for updating the database every second) is that after running the script, it continues to work, even if the user disconnects (or goes to another message in this case).
I added "ignore_user_abort (false);" however, since there is no connection to the mail client and the headers are already written, I do not think that "ignore_user_abort (false)"; can shoot.
I looked at the message to track massive email campaigns , and one from below "Haragashi" says:
"You can simply create a tracking handler that returns image tracking bytes by byte. After each byte, start the response and sleep for a certain period of time.
If you encounter a closed stream, the client closed the email (deleted or changed to another email that he knows).
During the exception, you know how long the client has been “reading” the email.
Does anyone know how I can “just build a tracking handler” like this, or learn about a solution that I can implement in my code that will cause the code to stop working when the user disconnects?