Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8179655
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T00:03:03+00:00 2026-06-07T00:03:03+00:00

I have been tracking emails for years using a "beacon" image and for those

  • 0

I have been tracking emails for years using a "beacon" image and for those clients that allow the images to download it has worked great to track how many people have opened the email.

I came across the service "DidTheyReadIt" which shows how long the client actually read the email, I tested it with their free service and it is actually pretty close to the times I opened the email.

I am very curious in how they achieve the ability to track this, I am certain that whatever solution is chosen it will put a lot of load on the server / database and that many of the community will reply with "Stop, No and Dont" but I do want to investigate this and try it out, even if its just enough for me to run a test on the server and say "hell no".

I did some googling and found this article which has a basic solution http://www.re-cycledair.com/tracking-email-open-time-with-php

I made a test using sleep() within 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 code above (other than updating the database every second) is that once the script runs it continues to run even if the user disconnects (or moves to another email in this case).

I added "ignore_user_abort(false);", however as there is no connection to the mail client and the headers are already written I dont think the "ignore_user_abort(false);" can fire.

I looked at the post Track mass email campaigns and one up from the bottom "Haragashi" says:

"You can simply build a tracking handler which returns the tracking image byte by byte. After every byte flush the response and sleep for a period of time.

If you encounter a stream closed exception the client has closed the e-mail (deleted or changed to another e-mail who knows).

At the time of the exception you know how long the client ‘read’ the e-mail."

Does anyone know how I could "simply build a tracking handler" like this or know of a solution I can implement into my code that will force the code to stop running when the user disconnects?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T00:03:04+00:00Added an answer on June 7, 2026 at 12:03 am

    I think the problem is that you aren’t doing a header redirect every so often. The reason that it is necessary is because once a script starts executing in PHP+Apache, it basically disregards the client until finished. If you force a redirect every X seconds, it makes the server re-evaluate if the client is still connected. If the client isn’t connected, it can’t force the redirect, and therefore stops tracking the time.

    When I played around with this stuff, my code looked like:

    header("Content-type: image/gif");
    while(!feof($fp)) {
        sleep(2);
        if(isset($_GET['clientID'])) {
            $redirect = $_SERVER['REQUEST_URI'];
        } else {
            $redirect = $_SERVER['REQUEST_URI'] . "&clientID=" . $clientID;
        }
        header("Location: $redirect");
        exit;
    }
    

    If the client id was set, then above this block of code I would log this attempt at reading the beacon in the database. It was easy to simply increment the time on email column by 2 seconds every time the server forced a redirect.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have been using Issue Tracking system for a week . Right now ,
Have been trying to encrypt an xml file to a string so that I
Have been looking on some tutorials for drawing canvas using SurfaceView, but the only
I have been using TortoiseSVN for some time and I really like it. I
I have been tasked with designing an application for tracking inventory on a mobile
I have been using Jira since 6months but haven;t been through any document related
I have been working on setting up a git server by using Paramiko to
I've been tracking down a really insidious bug at work. The event that seems
I have been writing a growing code base in Haskell. My problem is that
I have a report that tracks how long certain items have been in the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.