开发者

Tracking for How Long an Email was Read

Greeting Overflowers,

I am asked to code an email tracker using PHP. Email clients request my PHP script thinking it is an image (BODY's background). However, the client (namely Outlook 2007) hangs then (showing nothing) until my PHP script reaches its timeout.

<?php
define("DB_FILE", "sqlite:C:\wamp\www\database.sdb");
define("QUERY", "INSERT INTO Receipt (counter_id, reader_id, start_time, end_time) VALUES (%s, \"%s\", %d, %d)");
define("TIME_OUT", "10");

function track() {
    global $counter_id;
    global $reader_id;
    global $start_time;

    $end_time = time();

    $db = new PDO(DB_FILE);
    $db->exec(sprintf(QUERY, $counter_id, $reader_id, $start_time, $end_time));
}

$counter_id = $_GET["counter_id"];
$reader_id  = $_SERVER["REMOTE_AD开发者_开发知识库DR"];
$start_time = time();

set_time_limit(TIME_OUT);
register_shutdown_function("track");

while(!connection_aborted()) {
    echo "\n";
    ob_flush();
}
?>

It is the loop which should keep the HTTP connection alive for the period of client's reading the tracked email. Any thoughts on how to solve this ?

Regards


I'm afraid there's no sensible way of telling how long somebody has spent looking at an email. Mail clients simply aren't designed with that kind of data gathering in mind, and trying to force a network connection to stay open will merely cause the kind of problems you've run into.


There are people(companies) doing some simple tracking of how long an email is open by exploiting the fact that browsers will continue to request more frames for a gif (see the technique here) until you tell them that the last frame has been sent.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜