首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > asp.net >

关于google adsense统计的第三方插件的有关问题

2012-02-21 
关于google adsense统计的第三方插件的问题如何做到点击的google的广告,但也能统计到你点了哪个广告网站的

关于google adsense统计的第三方插件的问题
如何做到点击的google的广告,但也能统计到你点了哪个广告网站的信息的..比如这广告网站的网址等等..........

[解决办法]
把下面代码存为adLog.asp(分两部分)


<%@ CODEPAGE=65001 %>
<%
'///////////////////////////////////////////////////////////////////////////////
'// Google Adsense Click Logger
'// 作 者: duduwolf
'// 版权所有: 嘟嘟老窝(http://www.duduwolf.com/)
'// 技术支持: duduwolf@hotmail.com
'///////////////////////////////////////////////////////////////////////////////
%>
<% Option Explicit %>
<% On Error Resume Next %>
<% Response.Charset=WebCharset %>
<% Response.Buffer=True %>
<%
'=====定义全局变量=====

Const TextFile = "adLogDemo.txt " '保存点击数据的text文件,是相对路径,可以修改
Const AccessPassword = " " '查看点击时的访问密码,可以自行设定,如果无需身份认证,请将AccessPassword值改为 " "即可
Const SessionName = "google_ad_logger_demo " 'Session名称,用来保存访问密码到指定Session中
Const WebCharset = "utf-8 " '网站的编码类型,如果是GB-2312,请自行修改
Const UserName = "username " '用户名cookie,如果你的站没有用户cookie,就不用管了

'======================

Session.TimeOut = 30

Dim SendUrl, Url
SendUrl = "http:// " & Request.ServerVariables( "SERVER_NAME ") & Request.ServerVariables( "URL ")

Url = Request.ServerVariables( "URL ")

'=====接收客户端AJAX传过来的点击log数据保存到text中
If Request.ServerVariables( "REQUEST_METHOD ") = "POST " Then
Dim fso, f
If Request.QueryString( "act ") = "editLog " Then
Call SaveTxtFile()
Response.Redirect Url & "?act=editLog "
ElseIf Request.QueryString( "act ") = "login " Then
If Request.Form( "pwd ") = AccessPassword Then
Session(SessionName) = AccessPassword
Else
Response.Clear
End If
Response.Redirect Url & "?act=editLog "
Else
Set fso = Server.CreateObject( "Scripting.FileSystemObject ")
Set f = fso.OpenTextFile(Server.MapPath(TextFile), 8, true)
f.WriteLine(Now()& ", "&Request.Form( "url ")& ", "&Request.Form( "adurl ")& ", "&Request.ServerVariables( "REMOTE_ADDR ")& ", "&Request.Form( "refer ")& ", "&Request.Cookies(UserName))
f.Close
Response.Write "OK "
End If
Set f = Nothing
Set fso = Nothing
Response.End
End If

If Request.QueryString( "act ") = "script " Then
Dim str
str = "function XHConn() " & vbcrlf
str = str & "{ " & vbcrlf
str = str & " var xmlhttp = false, bComplete = false; " & vbcrlf
str = str & " try { xmlhttp = new ActiveXObject( " "Msxml2.XMLHTTP " "); } " & vbcrlf
str = str & " catch (e) { try { xmlhttp = new ActiveXObject( " "Microsoft.XMLHTTP " "); } " & vbcrlf
str = str & " catch (e) { try { xmlhttp = new XMLHttpRequest(); } " & vbcrlf
str = str & " catch (e) { xmlhttp = false; }}} " & vbcrlf
str = str & " if (!xmlhttp) return null; " & vbcrlf
str = str & " this.connect = function(sURL, sMethod, sVars, fnDone) " & vbcrlf
str = str & " { " & vbcrlf
str = str & " if (!xmlhttp) return false; " & vbcrlf


str = str & " bComplete = false; " & vbcrlf
str = str & " sMethod = sMethod.toUpperCase(); " & vbcrlf
str = str & " try { " & vbcrlf
str = str & " if (sMethod == " "GET " ") " & vbcrlf
str = str & " { " & vbcrlf
str = str & " xmlhttp.open(sMethod, sURL+ " "? " "+sVars, true); " & vbcrlf
str = str & " sVars = " " " "; " & vbcrlf
str = str & " } " & vbcrlf
str = str & " else " & vbcrlf
str = str & " { " & vbcrlf
str = str & " xmlhttp.open(sMethod, sURL, true); " & vbcrlf
str = str & " xmlhttp.setRequestHeader( " "Method " ", " "POST " "+sURL+ " " HTTP/1.1 " "); " & vbcrlf
str = str & " xmlhttp.setRequestHeader( " "Content-Type " ", " & vbcrlf
str = str & " " "application/x-www-form-urlencoded " "); " & vbcrlf
str = str & " } " & vbcrlf
str = str & " xmlhttp.onreadystatechange = function(){ " & vbcrlf
str = str & " if (xmlhttp.readyState == 4 && !bComplete) " & vbcrlf
str = str & " { " & vbcrlf
str = str & " bComplete = true; " & vbcrlf
str = str & " fnDone(xmlhttp); " & vbcrlf
str = str & " }}; " & vbcrlf
str = str & " xmlhttp.send(sVars); " & vbcrlf
str = str & " } " & vbcrlf
str = str & " catch(z) { return false; } " & vbcrlf
str = str & " return true; " & vbcrlf
str = str & " }; " & vbcrlf
str = str & " return this; " & vbcrlf
str = str & "} " & vbcrlf
str = str & vbcrlf
str = str & "var e = document.getElementsByTagName( " "iframe " "); " & vbcrlf
str = str & "function bindElement() { " & vbcrlf
str = str & " for (var i = 0; i < e.length; i++) { " & vbcrlf
str = str & " if(e[i].src.indexOf( 'googlesyndication.com ') > -1) { " & vbcrlf
str = str & " e[i].onfocus = trackLog; " & vbcrlf
str = str & " tag = e[i]; " & vbcrlf

热点排行