472,135 Members | 1,230 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,135 software developers and data experts.

Visitor Stats

Jon
Hi,

I'm writing a VERY BASIC stats databse for the default page of my web site.
I'm detecting various stats and saving them:

<%
visitdate = date()
visittime = time()
visitbrowser = Request.ServerVariables("HTTP_USER_AGENT")
visitreferer = Request.ServerVariables("HTTP_REFERER")
' code here for screen size
' code here to save to database
%>

I wish to also get screen resolution/size. I realise this is client side so
I can use:

<script language="JavaScript" type="text/javascript">
<!--
var screenW = screen.width
var screenH = screen.height
document.write(screenW + "x" + screenH)
//-->
</script>
But I can't save that into my database!!

Has anyone solved this problem before?

Thanks

Jon
Jul 19 '05 #1
4 2977
Have a form with a hidden field, use your javascript to populate the hidden
field(s) then post the form.

"Jon" <jon@SPAM_OFFtheexperts.co.uk> wrote in message
news:bs**********@sparta.btinternet.com...
Hi,

I'm writing a VERY BASIC stats databse for the default page of my web site. I'm detecting various stats and saving them:

<%
visitdate = date()
visittime = time()
visitbrowser = Request.ServerVariables("HTTP_USER_AGENT")
visitreferer = Request.ServerVariables("HTTP_REFERER")
' code here for screen size
' code here to save to database
%>

I wish to also get screen resolution/size. I realise this is client side so I can use:

<script language="JavaScript" type="text/javascript">
<!--
var screenW = screen.width
var screenH = screen.height
document.write(screenW + "x" + screenH)
//-->
</script>
But I can't save that into my database!!

Has anyone solved this problem before?

Thanks

Jon

Jul 19 '05 #2


Jon wrote:
Hi,

I'm writing a VERY BASIC stats databse for the default page of my web site.
I'm detecting various stats and saving them:

<%
visitdate = date()
visittime = time()
visitbrowser = Request.ServerVariables("HTTP_USER_AGENT")
visitreferer = Request.ServerVariables("HTTP_REFERER")
' code here for screen size
' code here to save to database
%>

I wish to also get screen resolution/size. I realise this is client side so
I can use:

<script language="JavaScript" type="text/javascript">
<!--
var screenW = screen.width
var screenH = screen.height
document.write(screenW + "x" + screenH)
//-->
</script>
But I can't save that into my database!!


You can try
<script type="text/javascript">
document.write('<img alt="" src="log.asp?width='
+ screen.width
+ '&height=' + screen.height
+ '" width="0" height="0">');
</script>
then in log.asp you store those values from the query string.
--

Martin Honnen
http://JavaScript.FAQTs.com/

Jul 19 '05 #3
Jon
> Have a form with a hidden field, use your javascript to populate the
hidden
field(s) then post the form.
Hi,

I'm writing a VERY BASIC stats databse for the default page of my web

site.
I'm detecting various stats and saving them:

<%
visitdate = date()
visittime = time()
visitbrowser = Request.ServerVariables("HTTP_USER_AGENT")
visitreferer = Request.ServerVariables("HTTP_REFERER")
' code here for screen size
' code here to save to database
%>

I wish to also get screen resolution/size. I realise this is client side

so
I can use:

<script language="JavaScript" type="text/javascript">
<!--
var screenW = screen.width
var screenH = screen.height
document.write(screenW + "x" + screenH)
//-->
</script>
But I can't save that into my database!!

Has anyone solved this problem before?

Thanks

Jon


When I considered the form idea I figured the problem is that it needs
posting, that is it won't work as the visitor goes to the page.

I'm going to have a try with Martins idea. I considered at the 'top' of the
page write the info to a cookie using javascript, at the 'end' of the page
retrieving this information using vbscript for my database?!

Jon
Jul 19 '05 #4
Jon
Sorted, thanks Martin.

The result:

index.htm or whatever:

<script language="JavaScript" type="text/javascript">
document.write('<img alt="" src="log.asp?width=' + screen.width +
'&height=' + screen.height + '" width="0" height="0">');
</script>

log.asp:

<%
dim conn, strsql, rsuser, strMDBPath
set conn=server.createobject("ADODB.Connection")
set rsuser=server.createobject("ADODB.Recordset")
strMDBpath = Server.MapPath("stats.mdb")
conn.open "PROVIDER=MICROSOFT.JET.OLEDB.4.0;DATA SOURCE=" & strMDBPath

visitdate = date()
visittime = time()
visitbrowser = Request.ServerVariables("HTTP_USER_AGENT")
visitreferer = Request.ServerVariables("HTTP_REFERER")
if visitreferer = "" then
visitreferer = "None shown"
end if
visitscreenresolution = request.QueryString("width") & "x" &
request.QueryString(+"height")

sql="INSERT INTO tblVisitors (visitdate, visittime, visitbrowser,
visitreferer, visitscreenresolution) VALUES ('" & visitdate & "', '" &
visittime & "', '" & visitbrowser & "', '" & visitreferer & "', '" &
visitscreenresolution & "');"

conn.Execute sql

conn.close
set rsuser=nothing
set conn=nothing
%>

Almost worthy of an FAQ ?????

Jon
Jul 19 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

6 posts views Thread by Ben | last post: by
3 posts views Thread by Bob Bedford | last post: by
5 posts views Thread by Peter Jenkins | last post: by
12 posts views Thread by FluffyCat | last post: by
9 posts views Thread by ankitdesai | last post: by
4 posts views Thread by botenremko | last post: by
2 posts views Thread by Monu | last post: by
8 posts views Thread by Spence | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.