计数器值不匹配,Google shortener与php访问者计数器


mismatched counter value, Google shortener vs php visitor counter

这是我试图实现的流程:

用户

  1. 点击共享链接(点击谷歌短链接)
  2. 重定向至计数器(counter.php
  3. 重定向到网页(网站页面)

我对谷歌短路器的计数器值和我自己的计数器值有问题——值总是不同。我的计数器值总是比谷歌的短值大,我自己的代码计数器有什么问题吗?

counter.hp:

//redirect to ?
$destination = "page1";
$destination_mobile = "page2";
$destination_article = "page3";
//connection
$con = mysqli_connect('localhost','root','','db_omron');
if (!$con) {    
    die('Could not connect: ' . mysqli_error($con));
}
//source contents
$id = mysqli_real_escape_string($con, $_GET['id']);
//internal
if($id=='101010'){$source='Quiz';}
else if($id=='101011'){$source='Quiz mobile';}
else if($id=='101020'){$source='Event';}
else if($id=='101021'){$source='Event mobile';}
else if($id=='101031'){$source='SMS';}
else if($id=='101040'){$source='News';}
else if($id=='101041'){$source='News mobile';}
else if($id=='101050'){$source='Banner';}
else if($id=='999990'){$source='tester';}
else{$source='n/a';}
date_default_timezone_set('Asia/Jakarta');
$today = date("Y-m-d");
//1.get old data
$sql="SELECT * FROM `click_counter` WHERE `id_source` = $id ORDER BY `date` DESC";
$result = mysqli_query($con,$sql);
$row = mysqli_fetch_array($result);
$oldTotal=$row['total'];
$oldDate=$row['date'];
//2.check if today is in database
if($today==$oldDate){
    //update
        $newTotal = $oldTotal+1;
        $newSqlUpdate="UPDATE `click_counter` SET `total` = '$newTotal' WHERE `id_source` = $id AND `click_counter`.`date` = '$today'";
        $newResult = mysqli_query($con,$newSqlUpdate);
    }else{
    //insert
        $newSqlInsert="INSERT INTO `click_counter` (`date`, `id_source`, `source`, `total`) VALUES ('$today', '$id', '$source', '1')";  
        $newEntry = mysqli_query($con,$newSqlInsert);
    }
//close connection
mysqli_close($con);
//redirecting page 
$a = substr("$id" , -1);
if ( $a == "1" ){
    header("Location:".$destination_mobile); 
}else if(($id=='102120') || ($id=='102130')){
    header("Location:".$destination_article); 
}else{
    header("Location:".$destination);
}
exit();

我对谷歌短路器的计数器值和我自己的计数器值有问题——值总是不同。我的计数器值总是比谷歌的短值大,我自己的代码计数器有什么问题吗?

谷歌分析通过JavaScript进行跟踪,因此,大多数机器人和任何未启用JS的用户的数字都不会被跟踪。这几乎可以肯定是你意见不一致的原因。