当前位置:首页 > Union > 正文内容

统计Google广告点击次数的方法

admin2007-01-26Union1155

象Google的广告,展示啥内容,都是由Google自己控制的,使用普通的页面提交连接的方式,我们是无法统计我们页面上的Google广告被点击了多少次,被谁点击了。因为这些页面都不受我们控制。下面介绍一个可以统计Google那样广告点击次数的方法。

下面代码中,我们在点击、移动等事件中,判断用户点击的是不是某个需要的范围内。然后进行计数,如果我们需要额外的记录,可以在这些事件函数中,向一个我们可控的页面进行提交。为了不影响页面的展示,这个页面被提交的页面,是在一个隐含的IFrame中实现的,具体看上述代码就明白了。

通过以上的方法,我们就可以实现不论点本网站的自己广告,还是Google广告,每点击一次,增加多少可用分这类的逻辑了。(当然这个逻辑可以更复杂)

代码:

<html>
<head>
<title>点击计数</title>
<script language="javascript">
<!--
function keyDown(e)
{
if (event.srcElement.tagName=='IFRAME'
&& event.clientX==-1
&& event.clientY==-1
&& event.fromElement=='[object]'http://a.ce100.com/list/){
/ 如果需要向其他页面提交
/document.adform.submit();
var num = parseInt(shownum.innerHTML);
shownum.innerHTML = num + 1;
}
return false;
}
document.onmousemove=keyDown;
document.onmouseover=keyDown ;
document.onmouseout=keyDown ;
document.onblur=keyDown;
//-->
</script>
</head>
<body>
<!-- 如果需要向另外一个页面传递参数,可以用下面的方式//-->
<form name="adform" method="post" action="ad_click.php" target='ad_click'>
<input name="uid" value='1922' type="hidden" id="uid">
<input name="keyid" type="hidden"
value='1119342517' id="keyid">
<input name="aid" type="hidden" id="aid">
</form>
<iframe name='ad_click' marginwidth="0"
marginheight="0" frameborder="0" scrolling="no"
src='about:blank' width="0" height="0">
</iframe>
<!--页面提交代码结束//-->

点击IFrame中的次数:<div id="shownum">
0</div>
<iframe name='ad_click' marginwidth="0"
marginheight="0" frameborder="0" scrolling="no"
src='http://www.csdn.net/' width="100"
height="100" style="width: 616px; height: 171px">
</iframe>
<br />
<br />
<a "http:/blog.joycode.com/" target="_blank">本页其它连接</a>
</body>
</html>

打赏

扫描二维码推送至手机访问。

版权声明:本文由友声网博客发布,如需转载请注明出处。

本文链接:https://hi.ys166.com/t/12

分享给朋友:

发表评论

访客

看不清,换一张

◎欢迎参与讨论,请在这里发表您的看法和观点。