我想要跟踪用户花在通过我发送的邮件上的秒数。我已经为它使用了php脚本。
<?php
// Time the request
$st = time();
$t = $st;
$ft = $st + 30;
ignore_user_abort(true);
set_time_limit(0);
$actual_link = "http://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]";
syslog(LOG_ERR,"URL : ".$actual_link);
while($st < $ft)
{
// Did the connection fail?
echo "HI \n";
flush();
ob_flush();
if(connection_status() != 0)
{
$duration1 = time() - $t;
syslog(LOG_ERR,"SKIM : User Stopped For TIME: ".$duration1);
break;
}
// Sleep for 1 seconds
sleep(1);
$st = $st + 1;
}
if($st >= $ft)
{
$duration = $st - $t;
syslog(LOG_ERR,"READ : User Stopped For TIME: ".$duration);
}
?>它是通过HTML在邮件内容中调用的,比如
<body>
<img src="http://url.../openduration.php/>
</body>现在,无论我花多长时间阅读邮件,阅读邮件的时长总是显示为23秒。我之前也试过关闭邮件,但没有效果。虽然当我在本地服务器上的网页上尝试时,这个脚本工作得很好,但我只尝试了Gmail。
发布于 2014-02-06 20:36:18
也许你正在谈论这件事
<?php
session_start();
$_SESSION['start'] = time();
/*here goes the code of email*/
$_SESSION['end'] = time();
echo "Start:".$_SESSION['start']."--"."End:".$_SESSION['end']."</br>";
echo "Total Execution time is : ".date("H:i:s",$_SESSION['end']-$_SESSION['start']);
?>发布于 2014-02-06 20:50:48
你不可能做你想做的事。Gmail缓存邮件中的所有图像,所以我认为在23秒没有收到任何东西之后,它会自动超时请求
https://stackoverflow.com/questions/21602922
复制相似问题