Redirection File

The Ad Rotator redirection file is an optional accessory file that allows you to trap clicks on an ad included on a page. It is an Active Server Page that you create to act as a middle script between the script containing the ad and the ad's URL. Each time a user clicks on an ad, the ad's URL is sent to this redirection file. Within this redirection file, you could easily add the name of the ad and other details such as the user's IP address to the web server log or a database or record it some other way.

However, the true power of this redirection file lies in your ability to add a script to this file to save more useful information than simply the number of times the ad was selected. To name just a few obvious examples, you could determine the contents of previously created session variables to get more details on the user: what scripts does he look at, what IP address is he coming from, and what software is he using. Frequently overlooked, this redirection file gives you the opportunity to track the details of your users and, thus, customize your site to its users.

The following is an example of some code from a redirection file:

<%
' Dimension local variables
Dim strUserName
Dim strRemoteAddress
Dim strURL
Dim strBrowserType

strUserName = Session("UserName")
strRemoteAddress = Request.ServerVariables("REMOTE_ADDR")
strURL = Request.QueryString("url")
strBrowserType = Session("UserBrowser")

[YOU COULD WRITE THE INFORMATION TO A TEXT FILE OR DATABASE HERE] Response.Redirect ...

Get ASP in a Nutshell, 2nd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.