Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP General > Visitor Stats

Reply
Thread Tools

Visitor Stats

 
 
Jon
Guest
Posts: n/a
 
      12-31-2003
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


 
Reply With Quote
 
 
 
 
TomB
Guest
Posts: n/a
 
      12-31-2003
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:bsuhae$o54$...
> 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
>
>



 
Reply With Quote
 
 
 
 
Martin Honnen
Guest
Posts: n/a
 
      12-31-2003


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/

 
Reply With Quote
 
Jon
Guest
Posts: n/a
 
      12-31-2003
> 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


 
Reply With Quote
 
Jon
Guest
Posts: n/a
 
      12-31-2003
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


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: Recording Visitor Stats Alexey Smirnov ASP .Net 2 09-18-2008 10:59 AM
Get Interface stats NOT VLAN stats on 6500 Mr Jibbles Cisco 3 07-03-2006 05:40 PM
Seeking advice on Aironet 1232 config for visitor and staff access Ned Cisco 3 09-25-2005 07:21 PM
Knowning IP Web site Visitor Mohammed Dwaikat ASP .Net 1 11-17-2004 09:44 AM
How to get the IP address of visitor of my website in ASP.net? Shige ASP .Net 1 01-13-2004 10:44 AM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57