Wrox Programmer Forums
|
BOOK: Beginning Dreamweaver MX/MX 2004 MX ISBN: 978-0-7645-4404-0; MX 2004 ISBN: 978-0-7645-5524-4
This is the forum to discuss the Wrox book Beginning Dreamweaver MX by Charles E. Brown, Imar Spaanjaars, Todd Marks; ISBN: 9780764544040
Please indicate which version of the book you are using when posting questions.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning Dreamweaver MX/MX 2004 MX ISBN: 978-0-7645-4404-0; MX 2004 ISBN: 978-0-7645-5524-4 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old August 17th, 2005, 09:27 AM
Authorized User
 
Join Date: Jul 2003
Posts: 68
Thanks: 0
Thanked 0 Times in 0 Posts
Default Problem with user statistics Application

I think this might be an IIS setting as the code works fine on another server. So that leads me to what should IIS be set at? I've never had a problem with the default before. I've got this set as an application with read ability.

Book:Beginning Dreamweaver MX
Page: 327

Here we 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.
Code:
The most popular first page for new users is:
    <%= GetFirstVisitedPage (True) %>
    <br>
    The most popular first page for returning visitors is:
    <%= GetFirstVisitedPage (False) %>
 
Old August 17th, 2005, 03:56 PM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

What exactly is the output of the two function calls? Do you only get a number? Or is the page maybe throwing an error that is hidden in the page's HTML?

Can you post the relevant part of the output of the functions in the browser's HTML??

Cheers,

Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
 
Old August 17th, 2005, 07:57 PM
Authorized User
 
Join Date: Jul 2003
Posts: 68
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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

 
Old August 18th, 2005, 08:42 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Right, I see.

Yeah, this code depends heavily on cookies so you need them enabled.
You could tweak the code so it also works with cookies disabled, but then each request from a cookieless client is counted as a new visitor....

Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.





Similar Threads
Thread Thread Starter Forum Replies Last Post
Statistics? seananderson SQL Server 2000 1 August 8th, 2007 08:12 AM
Problem installing application on user machine 4x4 ADO.NET 2 March 2nd, 2007 09:14 AM
Statistics fahad19 Pro PHP 0 January 26th, 2006 04:39 AM
Statistics bmains SQL Server ASP 7 January 13th, 2004 10:30 AM
Descriptive statistics with vb vdriet Excel VBA 1 September 8th, 2003 02:49 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.