google如何记录点击数
文章来源:http://atim.cn/read.php/585.htm
这一段时间都在弄公司的那个搜索。
由于整个搜索系统都是把所有内容先经过分词然后经过一系列的记分才得到更接近用户想要的结果。
其中一个计分内容就是结果的点击数。就是用户在搜索结果,选择适合用户所用的内容。
本来我用的是跳转的方式,就是用户在点击结果的时候,我把内容先跳转到记录点击的页面(click.php)中,然后再跳到用户需要的页面。
这样会有一个问题。就是如果click.php页面中出了问题跳不过去就会出现问题。
所以我使用了另一个方法--google记录点击数的方法。
以下面的结果
中山php
如果打开源代码页面,你会看到类似的代码。
<li class=g><h3 class=r><a href="http://atim.cn/post/zs-php.php" target=_blank class=l onmousedown="return clk(0,'','','res','1','','0CAgQFjAA')"><em>中山php</em> - 阿Tim's Blog - 梦想的天空</a></h3><div class="s">2009年3月2日 <b>
</b> 我已经写了好几年的php,在<em>中山php</em>开发网站上也算是一个先行者.不过中山使用php开发的网站是比较少.最开始大部分的网站都是asp,jsp开发的. <b>
</b><br><cite>atim.cn/post/zs-<b>php</b>.<b>php</b> - </cite><span class=gl><a href="http://203.208.39.132/search?q=cache:F0Om2u6ktU4J:atim.cn/post/zs-php.php+%E4%B8%AD%E5%B1%B1php&cd=1&hl=zh-CN&ct=clnk&gl=cn&client=pub-5434506002917399&st_usg=ALhdy2-TcJ5BVxYXLTdOHAzo0asak_KiWQ" target=_blank onmousedown="return clk(0,'','','clnk','1','')">网页快照</a></span></div>
![](https://www.cnblogs.com/Images/dot.gif)
![](https://www.cnblogs.com/Images/dot.gif)
其中在每个标题里都会有这一个
onmousedown="return clk(0,'','','res','1','','0CAgQFjAA')"
这一句应该就是用于记录结果的看看clk()具体做了什么
1
window.clk=function(d,e,f,j,k,l,m)
2
{
3
if(document.images)
4
{
5
var a=encodeURIComponent||escape,b=new Image,g=window.google.cri++;
6
window.google.crm[g]=b;
7
b.onerror=(
8
b.onload=(
9
b.onabort=function()
10
{
11
delete window.google.crm[g]
12
}
13
)
14
);
15
b.src=[
16
"/url?sa=T",
17
"\x26source\x3dweb",
18
e?"&oi="+a(e):"",
19
f?"&cad="+a(f):"",
20
"&ct=",a(j||"res"),
21
"&cd=",a(k),
22
"&ved=",a(m),
23
d?"&url="+a(d.replace(/#.*/,"")).replace(/\+/g,"%2B"):"",
24
"&ei=",
25
"JckAS9i7DpiOkQW6qdT7Cw",l
26
].join("")
27
}
28
return true
29
};
30![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
2
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedBlockStart.gif)
3
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
4
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
5
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
6
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
7
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
8
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
9
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
10
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
11
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
12
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
13
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
14
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
15
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
16
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
17
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
18
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
19
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
20
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
21
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
22
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
23
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
24
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
25
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
26
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
27
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
28
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
29
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedBlockEnd.gif)
30
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
上面的代码可以简化成
![](https://www.cnblogs.com/Images/OutliningIndicators/ContractedBlock.gif)
简单总结一下,
google记录点击数过程
当用户搜索后,看到比较合适的结果,当鼠标点下时就执行clk()函数。clk()就会生成一个图片对像,然后通过image对象的特性,生成了url的请求,这样就可以实现对点击的记录了。