gpt4 book ai didi

php - AdWords 严重误报点击次数 - 第 3 方跟踪页面丢失了 50% 的点击次数

转载 作者:行者123 更新时间:2023-11-29 02:57:56 25 4
gpt4 key购买 nike

我为几个客户管理 AdWords 帐户。我使用自己的自定义跟踪链接,该链接放置在我客户广告的 AdWords 目标 URL 框中(例如:http://www.mywebsite.com/track.php?id=1234567890)。

此链接指向一个简单的 PHP 页面,该页面记录 IP 地址,在远程计算机上放置一个 cookie,并将所有内容保存到 mysql 数据库中。然后它将用户转发到客户端的登录页面。

问题是,AdWords 将报告 10 次点击,但我的 PHP 跟踪页面只报告 5 次。为什么我的跟踪页面缺少这么多点击?

-在过去 30 天内,我的服务器正常运行时间为 100%。

-我的服务器启用了错误报告。没有错误记录。

-我的代码:

<?php

//determine which client/campaign this belongs to by reading get id from URL
if (isset($_GET['id'])) {
$tracker_id = $_GET['id'];
} else {
exit('Sorry, that ID is invalid.');
}

//if referrer is same page we just forwarded to, prevent rest of code from running to prevent redirect loop:
if (isset($_SERVER['HTTP_REFERER'])) {
if ($_SERVER['HTTP_REFERER'] == 'http://www.clientshomepage.com') {
//stop running script and send user back to where they originally came from:
echo '<script type="text/javascript">window.history.go(-1);</script>';
exit();
}
}

//check to see if remote machine already has cookie set:
if (!isset($_COOKIE[$tracker_id])) {
//create tracking id:
$cookie_id = mt_rand(100000000, 999999999);
//insert unique ID into cookie and place on remote machine:
setcookie($tracker_id, $cookie_id, time() + (86400 * 365), "/");
} else {
$cookie_id = $_COOKIE[$tracker_id];
}

//log the IP address of the person clicking:
if (isset($_SERVER['REMOTE_ADDR'])) {
$remote_addr = $_SERVER['REMOTE_ADDR'];
} else {
$remote_addr = '';
}

//include pdo/mysql credentials file:
require('pdo.php');

//insert collected data about this click into the database:
try {


$sql = "INSERT INTO mytable_name (tracker_id, cookie_id, remote_addr, click_time)
VALUES (:tracker_id, :cookie_id, INET_ATON(:remote_addr), :click_time)";

$stmt = $pdo->prepare($sql);

$stmt->execute(
array(
':tracker_id' => $tracker_id,
':cookie_id' => $cookie_id,
':remote_addr' => $remote_addr,
':click_time' => time()
)
);

$stmt = null;

} catch (PDOException $err) {
exit('Error Number: ' . $err->getCode() . '<br>' . 'Sorry, there was a database error. Please notify technical support.');
}

//forward user to landing page:
echo '<script>window.location = "http://www.clientslandingpage.com"</script>';


//in case redirect fails due to disabled javascript, redirect user old school style:
echo '<meta http-equiv="refresh" content="3;url=http://www.clientslandingpage.com"/>';

?>

最佳答案

插入数据库的页面可能被缓存。所以到 adwords 的元重定向是有效的,因为浏览器缓存了它,但你的服务器没有被击中,所以它不能保存到数据库。您可以尝试添加一些无缓存 header ,例如:

header("Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0");
header("Pragma: no-cache");

(假设您缺少来自同一用户的多次点击。)

关于php - AdWords 严重误报点击次数 - 第 3 方跟踪页面丢失了 50% 的点击次数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28376649/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com