【问题标题】:AdWords wildly misreporting number of clicks - 3rd party tracking page missing 50% of clicksAdWords 严重误报点击次数 - 第三方跟踪页面丢失了 50% 的点击次数
【发布时间】:2015-02-07 08:05:32
【问题描述】:

我为几个客户管理 AdWords 帐户。我使用自己的自定义跟踪链接放置在 AdWords 目标网址框中用于客户的广告(例如: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"/>';

?>

【问题讨论】:

    标签: php mysql google-ads-api


    【解决方案1】:

    插入到数据库的页面可能会被缓存。因此,元重定向到 adwords 正在工作,因为浏览器缓存了它,但您的服务器没有被命中,因此它无法保存到数据库。您可以尝试添加一些无缓存标头,例如:

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

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

    【讨论】:

    • 嗯...有趣的想法和我从未考虑过的事情。我刚刚查看了数据库,我有一个 IP 地址 (67.168.102.122),据报道,我在 24 小时内点击了我的广告 3 次。所以我认为这意味着缓存不是问题?
    猜你喜欢
    • 1970-01-01
    • 2023-03-05
    • 2013-06-29
    • 2017-07-03
    • 2015-10-28
    • 1970-01-01
    • 2010-09-30
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多