这是我想要实现的目标:
用户
counter.php
)我对来自Google缩短程序和我自己的计数器的计数器值有疑问 - 值总是不同的。我的计数器值总是比Google更短的值,我自己的代码计数器有什么问题吗?
counter.php:
//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();
答案 0 :(得分:0)
我对来自Google缩短程序和我自己的计数器的计数器值有疑问 - 值总是不同的。我的计数器值总是比Google更短的值,我自己的代码计数器有什么问题吗?
Google Analytics通过JavaScript跟踪,因此,大多数机器人和没有启用JS的任何用户都不会在其号码中进行跟踪。这几乎肯定是导致您出现差异的原因。