友声网

 找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索
开启左侧

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

[复制链接]
vikingr 发表于 2010-4-22 11:37 | 显示全部楼层 |阅读模式
<p>象Google的广告,展示啥内容,都是由Google自己控制的,使用普通的页面提交连接的方式,我们是无法统计我们页面上的Google广告被点击了多少次,被谁点击了。因为这些页面都不受我们控制。下面介绍一个可以统计Google那样广告点击次数的方法。 </p><p>下面代码中,我们在点击、移动等事件中,判断用户点击的是不是某个需要的范围内。然后进行计数,如果我们需要额外的记录,可以在这些事件函数中,向一个我们可控的页面进行提交。为了不影响页面的展示,这个页面被提交的页面,是在一个隐含的IFrame中实现的,具体看上述代码就明白了。 </p><p>通过以上的方法,我们就可以实现不论点本网站的自己广告,还是Google广告,每点击一次,增加多少可用分这类的逻辑了。(当然这个逻辑可以更复杂) </p><p>代码: </p><p>&lt;html&gt; <br />&lt;head&gt; <br />&lt;title&gt;点击计数&lt;/title&gt; <br />&lt;script language=&quot;javascript&quot;&gt; <br />&lt;!-- <br />function keyDown(e) <br />{ <br />if (event.srcElement.tagName=='IFRAME' <br />&amp;&amp; event.clientX==-1 <br />&amp;&amp; event.clientY==-1 <br />&amp;&amp; event.fromElement=='[object]'http://a.ce100.com/list/){ <br />/ 如果需要向其他页面提交 <br />/document.adform.submit(); <br />var num = parseInt(shownum.innerHTML); <br />shownum.innerHTML = num + 1; <br />} <br />return false; <br />} <br />document.onmousemove=keyDown; <br />document.onmouseover=keyDown ; <br />document.onmouseout=keyDown ; <br />document.onblur=keyDown; <br />//--&gt; <br />&lt;/script&gt; <br />&lt;/head&gt; <br />&lt;body&gt; <br />&lt;!-- 如果需要向另外一个页面传递参数,可以用下面的方式//--&gt; <br />&lt;form name=&quot;adform&quot; method=&quot;post&quot; action=&quot;ad_click.php&quot; target='ad_click'&gt; <br />&lt;input name=&quot;uid&quot; value='1922' type=&quot;hidden&quot; id=&quot;uid&quot;&gt; <br />&lt;input name=&quot;keyid&quot; type=&quot;hidden&quot; <br />value='1119342517' id=&quot;keyid&quot;&gt; <br />&lt;input name=&quot;aid&quot; type=&quot;hidden&quot; id=&quot;aid&quot;&gt; <br />&lt;/form&gt; <br />&lt;iframe name='ad_click' marginwidth=&quot;0&quot; <br />marginheight=&quot;0&quot; frameborder=&quot;0&quot; scrolling=&quot;no&quot; <br />src='about:blank' width=&quot;0&quot; height=&quot;0&quot;&gt; <br />&lt;/iframe&gt; <br />&lt;!--页面提交代码结束//--&gt; </p><p>点击IFrame中的次数:&lt;div id=&quot;shownum&quot;&gt; <br />0&lt;/div&gt; <br />&lt;iframe name='ad_click' marginwidth=&quot;0&quot; <br />marginheight=&quot;0&quot; frameborder=&quot;0&quot; scrolling=&quot;no&quot; <br />src='http://www.csdn.net/' width=&quot;100&quot; <br />height=&quot;100&quot; style=&quot;width: 616px; height: 171px&quot;&gt; <br />&lt;/iframe&gt; <br />&lt;br /&gt; <br />&lt;br /&gt; <br />&lt;a &quot;http:/blog.joycode.com/&quot; target=&quot;_blank&quot;&gt;本页其它连接&lt;/a&gt; <br />&lt;/body&gt; <br />&lt;/html&gt;</p>

RSS|无图版|手机版|友声网 ( 鲁ICP备15020090号-1 )|网站地图 | 点击这里给我发消息 |

GMT+8, 2024-4-19 14:07 , Processed in 0.160065 second(s), 7 queries , MemCache On.

Powered by Discuz! X

© ys166.com

快速回复 返回顶部 返回列表