Forum Moderators: DixonJones

Message Too Old, No Replies

I want a tool that reads the latest 300 or more visitors

         

chopin2256

7:51 pm on Apr 1, 2005 (gmt 0)

10+ Year Member



I like this handy tool, because I like to sift through the lastest visitors to see if my new keywords have been searched for. Currently I have "Latest 300 visitors" set up in my CPanel, however I am changing hosts. My new host most likely will not have this tool. Is there anyway to install "Latest 300 visitors" on their server? Will my new hosting company install it for me on their server?

HughMungus

7:55 pm on Apr 1, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



If I wanted to do this, I would have a setup where I log visitors myself in a database (which I do now).

chopin2256

8:09 pm on Apr 1, 2005 (gmt 0)

10+ Year Member



If I wanted to do this, I would have a setup where I log visitors myself in a database (which I do now).

I really wish I knew more about this. I realize all this information is in the log file, however I would like a nice visual. I have no clue how to do what you stated though. Its nice to have it automatically update in realtime.

chopin2256

9:44 pm on Apr 1, 2005 (gmt 0)

10+ Year Member



Can anyone help me on how to log my visitors and what keywords they used to find my site? This would be a different program from AWStats, it would be a realtime visitor logger. Please help, I am changing hosts and I will lose this feature that I find very convenient.

HughMungus

12:19 am on Apr 2, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



It's pretty easy.

This is my dumb way (which might happen to be the right way).

When someone hits your website from a search engine link, the search terms are usually in the URL.

So all you have to do is get the referer:

$referer = $_SERVER[HTTP_REFERER];

Then you parse it into parts to get the query string:

$parseurl = parse_url($referer);

So for a google search:

[google.com...]

$parseurl[host] = google.com
$parseurl[query] = q=widgets

Then you parse the query string into its individual variables to get the search term:

$string = parse_str($parseurl[query])
$string[q] = widgets

The you just update your db with the search engine (host) and the search term.

carguy84

3:28 am on Apr 3, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I don't know how to format it to make it more readable, but this is what I use in my ASP based site.
www.widget.com is my site name
widgetName is my internal site search variable that I also track.

HTH,
Chip-

Function insertSearch(intDomain, strSearchString)
insertSearch = execute( "sp_insertReferSearch", Array( _
Array( "domainId", adVarChar, adParamInput, Len( intDomain ), intDomain ), _
Array( "searchString", adVarChar, adParamInput, Len( strSearchString ), strSearchString ), _
Array( "userIp", adVarChar, adParamInput, Len( Request.ServerVariables("REMOTE_ADDR") ), Request.ServerVariables("REMOTE_ADDR") )))
End Function

REM -- Grab the referer string
strReferer = replace(Request.ServerVariables("http_referer"), "http://", "")
strCurrentPage = replace(Request.ServerVariables("SERVER_NAME"), "http://", "") & Request.ServerVariables("SCRIPT_NAME") & "?" & Request.QueryString()

if Session("bInitialReferer") <> 2 then
bInitialHit = true
end if

REM -- only care if there is a? or if it is an internal search
if ((bInitialHit or instr(strCurrentPage, "www.widget.com/search.asp?")) AND (instr(strReferer, "?") and instr(strReferer, "www.widget.com") = 0) or (len(Request("widgetName")) > 0 and instr(strCurrentPage, "www.widget.com/search.asp?"))) then
if instr(strCurrentPage, "www.widget.com/search.asp?") then
arrSplitURL = Split(replace(strCurrentPage, "/search.asp", ""), "?")
else
arrSplitURL = Split(strReferer, "?")
end if

strRefURL = arrSplitURL(0)
strQS = arrSplitURL(1)

REM -- Regular Expression
set objRegEx = New RegExp

objRegEx.Global = true
objRegEx.IgnoreCase = true

REM -- used below to see if it is a matching Domain Name we care about
bStoredURL = True
Select Case strRefURL

case "www.google.com/search", "google.com/search"
objRegEx.Pattern = "q=.*&?"
set objREmatches = objRegEx.Execute(strQS)
for each REmatch in objREmatches
strSearchString = replace(REmatch, "q=", "")
next
intDomain = 1

case "search.yahoo.com/search", "search.yahoo.com/search"
objRegEx.Pattern = "p=.*&?"
set objREmatches = objRegEx.Execute(strQS)
for each REmatch in objREmatches
strSearchString = replace(REmatch, "p=", "")
next
intDomain = 2

REM -- Internal search
case "www.widget.com", "widget.com"
objRegEx.Pattern = "widgetName=.*&?"
set objREmatches = objRegEx.Execute(strQS)
for each REmatch in objREmatches
strSearchString = replace(REmatch, "widgetName=", "")
next
intDomain = 3

case "search.msn.com/results.asp", "search.msn.com/results.aspx"
objRegEx.Pattern = "q=.*&?"
set objREmatches = objRegEx.Execute(strQS)
for each REmatch in objREmatches
strSearchString = replace(REmatch, "q=", "")
next
intDomain = 4

case "www.business.com/search/rslt_default.asp", "www.business.com/search/rslt_websites.asp"
objRegEx.Pattern = "query=.*&?"
set objREmatches = objRegEx.Execute(strQS)
for each REmatch in objREmatches
strSearchString = replace(REmatch, "query=", "")
next
intDomain = 5

case "search.lycos.com/default.asp"
objRegEx.Pattern = "query=.*&?"
set objREmatches = objRegEx.Execute(strQS)
for each REmatch in objREmatches
strSearchString = replace(REmatch, "query=", "")
next
intDomain = 6

case "go.google.com/hws/search"
objRegEx.Pattern = "q=.*&?"
set objREmatches = objRegEx.Execute(strQS)
for each REmatch in objREmatches
strSearchString = replace(REmatch, "q=", "")
next
intDomain = 7

case "www.altavista.com/web/results"
objRegEx.Pattern = "q=.*&?"
set objREmatches = objRegEx.Execute(strQS)
for each REmatch in objREmatches
strSearchString = replace(REmatch, "q=", "")
next
intDomain = 8

case else
bStoredURL = false
end select
REM -- if is is a domain name we monitor, save the search

if bStoredURL then
arrRemoveAmp = Split(strSearchString, "&")
strFormat = replace(arrRemoveAmp(0), "+", " ")
insertSearch intDomain, strFormat
end if

end if

carguy84

3:33 am on Apr 3, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



btw, yes, it's not a great way to do it I know but it works :)