NCS Logo - Click for home page Northstar Developer Center
Platforms
All Platforms
.NET Framework (1.x - 4.x)
Active Server Pages
ASP.NET
C#
SQL Server
VB.NET
Visual Basic

Keywords
.NET Data Types
.NET E-mail
.NET Events
.NET Functions
.NET Object Programming
.NET System.Configuration
.NET System.Diagnostics
.NET System.IO
.NET System.Net
.NET System.Net.Sockets
Active Data Objects
ASP Architecture
ASP Black Belt
ASP Built-in Functions
ASP Built-in Objects
ASP Debugging
ASP Performance
ASP Security
ASP Syntax
ASP.NET Authentication
ASP.NET Controls
ASP.NET Data Access
ASP.NET Features
ASP.NET Master Pages
ASP.NET Page Events
ASP.NET Security
ASP.NET ViewState
Atom
Certifications
COM, DCOM, COM+
Data Access
E-Mail
Errors
Exporting Data
HTML Tips
IIS
Object-Oriented Programming
RSS
SQL
Uncategorized ASP Tips
VB API Programming
VB Forms
VB Syntax
XML

Book Support
Visual Basic 6 Bible
ASP Bible
ASP Weekend Crash Course
ASP.NET At Work
Creating Web Services

Finding Out Where the User Came From

Written by Eric Smith, Northstar Computer Systems LLC

In web traffic analysis, it's helpful to find out how users found your site, especially if the user came from a link on another page. A reader asked how to get this information, and it's really easy to do. In the page headers, there is an HTTP variable called HTTP_REFERER which contains the URL that a user hit immediately before coming to your site. You can access this information through the ServerVariables collection, as shown in this example:
<a href="<% = Request.ServerVariables("HTTP_REFERER")%>">Go back to where you came from</a>
If you have another page linking to this one, the HTTP_REFERER variable will show that as the previous page. Unfortunately, this method is not always reliable. In my own testing, putting this code on a page and then typing in its URL caused the variable to be blank.

If you need a better way to track user movement through your site, you can add a URL parameter or session variable indicating the page you're on. In page #1, you set the value to some constant or code. In page #2, you first record the current value of the variable, and then change the value to refer to the current page. As you work through the site, you'll have a "linked list" of how the user navigated the site.

Keywords: [ Uncategorized ASP Tips ]

Publication Date: 11/1/1999