我正在尝试为从 wordpress 发出的电子邮件实现自定义跟踪像素。
感谢这些帖子:
Tracking email with PHP and image
Tracking email opens with a real image
尤其是
http://www.phpdevtips.com/2013/06/email-open-tracking-with-php-and-mysql/
我能够实现核心思想。
电子邮件通过以下方式加载跟踪像素
<img src="https://www.example.com/tracking.php?order_id=1" width="100" height="100" />
并在 tracking.php 中
$graphic_http = 'https://www.example.com/GIF-example.gif';
header('Content-Type: image/gif');
readfile( $graphic_http );
在浏览器中打开 tracking.php 文件会打开 gif 图像以供下载。
但是,跟踪像素/跟踪图像不会显示在 Gmail 电子邮件中。只有损坏的图像 Logo ,当我单击以显示图像时,此链接已打开
其中指出 Google 404:
Google 404。这是一个错误。
The requested URL/proxy/l2xUKFGnNFKm64zEYmJhOcUmEJm15w9MC1txRRF01tpKlcL3t3O16aMJgbYQkucBySV0xV2T0EsCwikOAC0Z4em6uPzSs38lkHrYBvosRRAk14EfPoEXqC5JdLxRm8ToZmGSQqt_RwHCaBE_3uLgQDVEB05Rdtkq-Xzuw30=s0-d-e1-ft was not found on this server.我们知道的就这些。
看来是Google的代理无法读取php脚本的问题。 tracking.php 和 GIF-example.gif 文件都拥有 775 权限并且可以公开访问。
在 Hotmail 上这确实有效,所以这似乎确实是 Google 代理的问题。
有人知道如何让 Google 代理访问此跟踪像素吗?
最佳答案
我找到了答案:问题出在 Google 代理和问号上?在 https://www.example.com/tracking.php?order_id=1
Google 代理地址被弄乱了,因为它已经有一个问号并导致 404。
我使用 https://www.example.com/tracking.php/order_id=1
解决了它,然后在 tracking.php 上我没有使用 $_GET
但 $_SERVER['REQUEST_URI']
并解析了 /order_id=
字符串。
跟踪像素显示在 Gmail 中,并在 tracking.php 脚本中进行跟踪。
关于php - 跟踪像素和 Gmail 代理的问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38226003/