
March 4th, 2003, 07:36 PM
|
 |
Contributing User
|
|
Join Date: Mar 2003
Location: San Diego
Posts: 55
Time spent in forums: 6 h 11 m 33 sec
Reputation Power: 8
|
|
|
source code
Quote: | Sorry to hear the perl script didn't work on your server |
My hosting company has active perl and it never works as well as stardard cgi perl... anyhow, here is the core source-code for script I wrote:
Quote:
<%
Dim UserAgent, RemoteHost, RemoteAddr, BOT, BotType, gbDomainRequested, gbFullDomainName, gbPage
'Clean up the url and domain name
gbDomainRequested = LCase(Request.ServerVariables("SERVER_NAME"))
gbDomainRequested = Replace(gbDomainRequested, "www.", "")
gbFullDomainName = gbDomainRequested
gbDomainRequested = Replace(gbDomainRequested, ".com", "")
gbDomainRequested = Replace(gbDomainRequested, ".net", "")
gbDomainRequested = Replace(gbDomainRequested, ".org", "")
gbDomainRequested = Replace(gbDomainRequested, ".biz", "")
gbDomainRequested = Replace(gbDomainRequested, ".info", "")
gbPage = Replace(Request.ServerVariables("URL"), gbDirectoryName, "")
'grab the visitor
UserAgent = Request.ServerVariables("HTTP_USER_AGENT")
RemoteHost = Request.ServerVariables("REMOTE_HOST")
RemoteAddr = Request.ServerVariables("REMOTE_ADDR")
'Use to simulate a visit
'UserAgent = "Googlebot"
'RemoteHost = ".googlebot.com"
'RemoteAddr = "216."
BOT = False
'Is it the googlebot?
If InStr(UserAgent, "Googlebot") > 0 Then BOT = True
If InStr(RemoteHost, ".googlebot.com") > 0 Then BOT = True
If BOT = True Then
'Hooray!
'If so, which bot is it?
If Left(RemoteAddr, 4) = "216." Then
BotType = "Deep Bot"
Else
BotType = "FreshBot"
End If
'Record the vist!
set Tracker = Server.CreateObject("ADODB.Recordset")
Tracker.ActiveConnection = MM_CommerceHelper_STRING
Tracker.Source = "SELECT * FROM GoogleTracker"
Tracker.CursorType = 2
Tracker.CursorLocation = 3
Tracker.LockType = 3
Tracker.Open()
Tracker.AddNew()
Tracker.Fields("DomainName") = gbFullDomainName
Tracker.Fields("Page") = gbPage
Tracker.Fields("BotType") = BotType
Tracker.Update()
Tracker.Close()
End If
%>
|
Just include this file on each page you want to track (<!--#include file="GoogleTracker/GoogleTracker.asp" -->), record and display the visit how you wish. It will display the domain name, page file name, time of visit, and type of bot!
|