我有一个安全的图像像素(下面的示例)用于跟踪转化,但我只希望它在50%的时间内加载,这样做的最简单方法是什么?
<img src="https://tt1.zedo.com/ads2/t?o=376447;h=1231184;z=[timestamp]" width="1" height="1" BORDER="0">
I think you should store some counter in the session.
example:
$_SESSION['counter']++;
if ($_SESSION['counter'] % 2 == 0) {
echo '<img src="https://tt1.zedo.com/ads2/t?o=376447;h=1231184;z=[timestamp]" width="1" height="1" BORDER="0">';
}
您甚至可以在没有PHP的情况下在客户端上执行if(Math.random> 0.5)$('body')。append(“”)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.