SitePoint Sponsor

User Tag List

Results 1 to 2 of 2

Thread: User Tracking

  1. #1
    SitePoint Member mar0364's Avatar
    Join Date
    May 2003
    Location
    florida
    Posts
    17
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    User Tracking

    I changed my browser setting to accept all cookies and it works.

    I'm trying to see how many user visit a page and which page they are visiting. Here is how I have gone about it. Create a sub and a function and place it into an include file.

    The sub checks the cookie for new or returning and gets the URL using the servervariable.
    Code:
    Sub SetFirstVisitedPage ()
        Dim sPageName
        sPageName = Request.ServerVariables("URL")
        If Len(Request.Cookies("CheckFirstPage")) = 0 Then
          If Len(Request.Cookies("RevisitingUser")) = 0 Then
            ' New user
            Application("Page_New_" & sPageName) = _
              Application("Page_New_" & sPageName) + 1
          Else
            ' Revisiting user
            Application("Page_Revisit_" & sPageName) = _
              Application("Page_Revisit_" & sPageName) + 1
          End If
          Response.Cookies("CheckFirstPage") = "Done"
          Response.Cookies("RevisitingUser") = "Yes"
          Response.Cookies("RevisitingUser").Expires = Date() + 30
        End If
      End Sub

    Next we have a function that return a result. This function combines takes the name or the URL and the number of visits and combine them into a variable named "GetFirstVisitedPage". See last line of function.
    Code:
    Function GetFirstVisitedPage(ByVal bNewUsers)
        Dim iMaxHits
        Dim sAppVar
    	Dim sFirstVisitedPage
        iMaxhits = 0
         For Each sAppVar in Application.Contents()
          If Left(sAppVar, 5) = "Page_" Then
            If bNewUsers = True then
              If Left(sAppVar, 9) = "Page_New_" Then
                If CInt(Application(sAppVar)) > iMaxHits Then
                  iMaxHits = Application(sAppVar)
                  sFirstVisitedPage = Right(sAppVar, Len(sAppVar) - 9)
                End If
              End If
            Else
              If Left(sAppVar, 13) = "Page_Revisit_" Then
                If CInt(Application(sAppVar)) > iMaxHits Then
                  iMaxHits = Application(sAppVar)
                  sFirstVisitedPage = Right(sAppVar, Len(sAppVar) - 13)
                End If
              End If
            End If
          End If
        Next  
        GetFirstVisitedPage = sFirstVisitedPage & " with " & iMaxHits & " hits "
      End Function

    The result of this should allow me to read the following to a page and get the page location/url and the number of hits for that page. However it will only give me the number of hits.
    The most popular first page for new users is:
    Code:
    <%= GetFirstVisitedPage (True) %>
    	<br>
    	The most popular first page for returning visitors is:
    	<%= GetFirstVisitedPage (False) %>

    Thanks!
    Rich

    Please take look at the server settings in this image and tell if they look correct. What exactly should they?
    Attached Images Attached Images
    Last edited by mar0364; Aug 17, 2005 at 17:01. Reason: May have found issue but still need help

  2. #2
    SitePoint Member oldwebgeek's Avatar
    Join Date
    Mar 2003
    Location
    New York
    Posts
    0
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Can you elaborate a little more. I'd like to try and assist you.

    What results are you getting now when you run the script?
    Nolan Interactive: Web services and software for business
    Web Descant: Website Design and Marketing Blog
    No-Nonsense Hosting: Business Web hosting
    WebmailASP: Webmail client for ASP and IIS


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •