| Welcome to Webforumz.com. |
|
Oct 27th, 2007, 02:38
|
#1 (permalink)
|
|
Most Reputable Member
Join Date: Feb 2004
Location: Borneo
Age: 27
Posts: 1,567
|
My Page Statistic [Browser & OS]
Hello, since this asp thread is not much thing going on lately, let me make you guys busy for quiet some time!
I have a question. I have notice that there is some discussion in this forum regarding page statistic (their page statistic) and I am really interested to learn how to do that.
Ok, I know that I should have a code for checking the user browser and OS: - <%=Request.ServerVariables("HTTP_USER_AGENT")%> = OS and browser
- <% =Request.ServerVariables("REMOTE_ADDR")%> = IP address
That would display: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.8) Gecko/20071008 Firefox/2.0.0.8
That would be a long list.
Basically, what I am trying to say here is I wanted to create a page in my site that will display all this page statistic info. Something like:
My Page Statistic - Browser: ??
- Operating System: ??
- IP Address: ??
Each time a unique user visited my site/page, I want to keep the this info in my database.
Thanks..
__________________
|
|
|
Oct 27th, 2007, 23:16
|
#2 (permalink)
|
|
Junior Member
Join Date: Oct 2007
Location: Israel
Age: 20
Posts: 31
|
Re: My Page Statistic [Browser & OS]
what kind on an info do you want to keep?
Basically, the Ip address can be the identifier column for your table and you can keep any user that his IP does not exists on the database.
to that very basic 1 column table you will add to each row any other information on the user that you want (you can look for the info on the serverVaraibles list).
more advanced, to each row you can add the current date and time and get more specific on your statics (e.g. alltime, last year, last month, last week, today, 5 minutes ago - online).
i mean to something like this: http://extremetracking.com/open;unique?login=alexucho
if you get troubles i can help.
|
|
|
Oct 29th, 2007, 02:58
|
#3 (permalink)
|
|
Most Reputable Member
Join Date: Feb 2004
Location: Borneo
Age: 27
Posts: 1,567
|
Re: My Page Statistic [Browser & OS]
Quote:
Originally Posted by Eran
what kind on an info do you want to keep?
Basically, the Ip address can be the identifier column for your table and you can keep any user that his IP does not exists on the database.
|
Info like their Operating system (windows or mac...), their browser, and their IP address.
Ok, I must have a field (to store the IP address of the visitor) in my table...
Once they hit my site address, the main page will perform a checking of their IP address, If it exist in the database, continue to surf my site. If it does not exist, save their browser, IP address as well as their OS into my database.
Ok, I get it now..
Thanks.
__________________
Last edited by Monie; Oct 29th, 2007 at 03:00.
|
|
|
Oct 30th, 2007, 05:14
|
#4 (permalink)
|
|
Most Reputable Member
Join Date: Feb 2004
Location: Borneo
Age: 27
Posts: 1,567
|
Re: My Page Statistic [Browser & OS]
Hai everyone,
I've come up with this simple code (but I ended up doing it for the whole day tho..)
It basically capture the user info like the type of browser they are using, their server software and the most important thing is their IP address, and store them in the database.
- HTML: Select all
<%
Dim ipadd, browser, serversw
ipadd = Request.ServerVariables("remote_addr")
browser = Request.ServerVariables("http_user_agent")
serversw = Request.ServerVariables("server_software")
%>
- HTML: Select all
<%
Do while not pg.EOF
If pg("ipaddress") = ipadd Then 'If the user IP address appear to be exist in the database already, just redirect them to the main page!
pg.Close
pgConn.Close
set pg=nothing
set pgConn=nothing
Response.Redirect("default.asp")
End If
pg.MoveNext
Loop
'If the user IP address don't exist in the database, save them to the database..!
Set pg = pgConn.Execute("INSERT INTO pagerank (ipaddress, browser, serversoftware) VALUES ('" & ipadd & "', '" & browser & "', '" & serversw & "')")
Response.Redirect("default.asp")
%>
Now I can do my page rank statistic...
If there is any better way, please share, Thanks..
__________________
Last edited by Monie; Nov 1st, 2007 at 07:19.
|
|
|
Nov 1st, 2007, 14:01
|
#5 (permalink)
|
|
Junior Member
Join Date: Oct 2007
Location: Israel
Age: 20
Posts: 31
|
Re: My Page Statistic [Browser & OS]
amm, yes you can.
instead of looping all your database you can do it with a simpler query.
something like this:
- HTML: Select all
sql = "SELECT * FROM pagerank WHERE ipaddress='" & ipadd & "'"
...
if not pg.EOF
Set pg = pgConn.Execute("INSERT INTO pagerank (ipaddress, browser, serversoftware) VALUES ('" & ipadd & "', '" & browser & "', '" & serversw & "')")
I'm just not sure if my is statement is correct
secondly, why are need the redirection for?
you can make this code rows as a new page and add it to each page (you can add to the static the current page...).
that way, if a user will surf directly to "default.asp" the static will "know" him.
and to loss some extra load on your database you will create a cookie (with chocolate's chips), after you adding a new user (by unique IP) or verifying that this user is already in exists in your database, that says 'hi! did i surfed here before?'.
and finally you will add the damn question if the cookie exist than do the ip check.
good luck m8 :P
|
|
|
Nov 2nd, 2007, 03:51
|
#6 (permalink)
|
|
Most Reputable Member
Join Date: Feb 2004
Location: Borneo
Age: 27
Posts: 1,567
|
Re: My Page Statistic [Browser & OS]
Wow.. Thanks again Eran!
I'll have a look at your way and try them in my page ASAP.
I'll let you know if I manage to do it 
__________________
|
|
|
Nov 2nd, 2007, 04:46
|
#7 (permalink)
|
|
Most Reputable Member
Join Date: Feb 2004
Location: Borneo
Age: 27
Posts: 1,567
|
Re: My Page Statistic [Browser & OS]
Hai Eran, I have come up with this! Looks more effective tho..
I never tought of that before.. Thanks to you
About the cookie things.. I might learn that bit. I am using session variable in my login page tho..
- Code: Select all
Set pg = pgConn.Execute("SELECT * FROM mypagerank WHERE ipaddress = '" & ipadd & "' ")
If not pg.EOF Then
'If the user IP address exist in the database, do nothing and close connection!
pg.Close
pgConn.Close
set pg=nothing
set pgConn=nothing
Else
'If it don't exist, Saved them!
Set pg = pgConn.Execute("INSERT INTO mypagerank (ipaddress, browser, serversoftware, year, month) VALUES ('" & ipadd & "', '" & browser & "', '" & serversw & "', '" & visitYear & "', '" & visitMonth & "')")
End If
__________________
|
|
|
Nov 2nd, 2007, 08:07
|
#8 (permalink)
|
|
Junior Member
Join Date: Oct 2007
Location: Israel
Age: 20
Posts: 31
|
Re: My Page Statistic [Browser & OS]
any time
cookies is a very like the same as sessions except that the cookie is saved only on the user pc and session cost you on the server as well.
cookies - unsecured. any website or man or hacker can see it (you can see it on the cookies folder).
session - secured. saved on the server. :secret:
the thing is that we don't want unnecessary data on the server. it will slow your website down. therefor try to use as slightly as you can with sessions.
first, I saw you use redirection and by that users can bypass your static page directly to your main page so i suggest you to put the static code on any page that you want without the redirection thing.
second, the cookie thing is to loose stress on the database that when i reload the page it won't connect to the db again for nothing.
3rd, you got this terrific site that can be very useful for ya
http://www.w3schools.com/asp/asp_cookies.asp
 eace:
|
|
|
Nov 2nd, 2007, 08:18
|
#9 (permalink)
|
|
Most Reputable Member
Join Date: Feb 2004
Location: Borneo
Age: 27
Posts: 1,567
|
Re: My Page Statistic [Browser & OS]
you seems good in asp Eran  nice to have you here..
As you notice, I have throw away the redirect thing and seems that I coded them in a very effective way.
About the cookies thing, that I will keep that in mind.
Now, everytime the user visit my main page, the page will "rerun" the If Then Else statement.
That I have to look into now....
__________________
|
|
|
Nov 5th, 2007, 05:54
|
#10 (permalink)
|
|
Most Reputable Member
Join Date: Feb 2004
Location: Borneo
Age: 27
Posts: 1,567
|
Re: My Page Statistic [Browser & OS]
Solved it!
Just add some session checking and the code will no longer be run everytime the page load/refreshed!
- Code: Select all
If Session("saved") <> "saved" Then 'If session value is not equal the value "saved", this code will not be executed!
open the database connection, saved the user IP address and
set session("saved") = "saved"
End If
__________________
|
|
|
Nov 5th, 2007, 13:28
|
#11 (permalink)
|
|
Junior Member
Join Date: Oct 2007
Location: Israel
Age: 20
Posts: 31
|
Re: My Page Statistic [Browser & OS]
i meant u do that on cookies to easier the server.
nice work :P
|
|
|
Nov 6th, 2007, 00:27
|
#12 (permalink)
|
|
Most Reputable Member
Join Date: Feb 2004
Location: Borneo
Age: 27
Posts: 1,567
|
Re: My Page Statistic [Browser & OS]
yeah, I am learning that now, I mean how to use cookies instead of session object
Thanks for the advice.
__________________
|
|
|
Nov 12th, 2007, 01:50
|
#13 (permalink)
|
|
Most Reputable Member
Join Date: Feb 2004
Location: Borneo
Age: 27
Posts: 1,567
|
Re: My Page Statistic [Browser & OS]
and... my final question...!
I am using this code to get the browser type: <%=Request.ServerVariables("HTTP_USER_AGENT")%> = "a long list of browser type here"
and in my sql database I will write like this:
SELECT * FROM mydatabase WHERE browser = "a long list of browser type here"
Is there a way for me to get the result like this:
browser = Firefox or EI7 or Safari or IE6.. instead of the long list I get from the code above?
Thanks..
__________________
|
|
|
Nov 15th, 2007, 16:18
|
#14 (permalink)
|
|
Junior Member
Join Date: Oct 2007
Location: Israel
Age: 20
Posts: 31
|
Re: My Page Statistic [Browser & OS]
nop
Once I copied i file from "webwiz" forum that can do what you want - if you want you can search it on their website...
the main idea is to check if IE6 is in the text and to determine the browser type.
they got a long list of browser type and versions there. very useful. i suggest you go search or ask for it on there website. gL!
|
|
|
Nov 17th, 2007, 07:11
|
#15 (permalink)
|
|
Most Reputable Member
Join Date: Feb 2004
Location: Borneo
Age: 27
Posts: 1,567
|
Re: My Page Statistic [Browser & OS]
I would be thankful if you could send me the file that you are talking about 
I don't know what to search for Eran..
Thanks.
__________________
|
|
|
Nov 17th, 2007, 17:38
|
#16 (permalink)
|
|
Junior Member
Join Date: Oct 2007
Location: Israel
Age: 20
Posts: 31
|
Re: My Page Statistic [Browser & OS]
browser.txt
web_wiz_forums_lite_v7[1].9
i didn't found this on their latest versions so maybe they upgraded this old function :] try to ask them on their community... 
|
|
|
Nov 21st, 2007, 06:07
|
#17 (permalink)
|
|
Most Reputable Member
Join Date: Feb 2004
Location: Borneo
Age: 27
Posts: 1,567
|
Re: My Page Statistic [Browser & OS]
Wow Eran, that code is good!
Brilliant you!
__________________
|
|
|
Nov 23rd, 2007, 12:03
|
#18 (permalink)
|
|
Junior Member
Join Date: Oct 2007
Location: Israel
Age: 20
Posts: 31
|
Re: My Page Statistic [Browser & OS]
yeah, I've been used it too once...
|
|
| | | |