KnowledgeBase - How do I create a redirect page using HTML, JavaScript, or ASP?

How do I create a redirect page using HTML, JavaScript, or ASP?

« Go Back
Webtrends Legacy Products
How do I create a redirect page using HTML, JavaScript, or ASP?
For products:
Webtrends Analysis Suite 7.0x
Webtrends Log Analyzer Advanced 8.0x
Webtrends Log Analyzer 8.0x
Webtrends Log Analyzer 7.0x
Webtrends Reporting Center 6.0x
Webtrends Reporting Center 5.0x
Webtrends Reporting Center 4.0x

Last modified: 1/1/2011
 A redirect page is a page that causes an Internet browser to be immediately redirected from one HTML page to another. There are several ways in which redirect pages can improve the usefulness and accuracy of your Webtrends reports. These will be discussed in detail in this article.
The most common use of a redirect page is to simplify Advertising Analysis. Let us use an example: assume that your Web page is currently running advertisements for two other sites, and and send you a check each month equal to the number of visitors you have referred to them, and you would like to verify that their numbers of referrals are accurate. Without redirect pages, this is quite difficult, because there is no way to analyze the destinations of users who leave your Web site via a normal link. This is not a shortcoming in Webtrends software, this is just the way browsers and servers work. The reason for this is that when a user follows a link that takes him or her to another company's Web site, the user's browser goes directly to that company's Web site; it does not inform your server that the user has left. If the user was to follow an outgoing link, then click the "Back" button in his or her browser to get back to your Web site, and then continues browsing, your web server would never know. So, if your Web server is never notified that the user left (and Webtrends receives all of its information from your Web server), how can you tell where the user went? The answer is through the use of redirect pages. Let us say you make two redirect pages: one is called redirect_ABC.html, and the other is called redirect_XYZ.html.
 Now, you will have to alter your site's advertising, so that when a user clicks on the advertisement for, he or she is not sent directly to that site, but instead, sent to redirect_ABC.html. Once the user arrives at the redirect_ABC.html page, his or her browser immediately leaves and goes to Normally, this will happen so fast that the user will not know there was a redirect page; he or she clicks the advertisement, and a moment later appears. The user never realizes that he or she took a detour to The reason you want the user to go through this redirect is that it will show up in your server's log file. When you analyze your log files, you will see that you received a number of hits to the redirect_ABC.html page, and you will see a number of hits to as well. Each of those hits corresponds to a user who clicked on the advertisement, was sent to the redirect page (which was noted in your Web servers log file), and was then redirected to the or web page (depending, of course, on which advertisement the user clicked). So, if your Webtrends report tells you that you received 100 hits to redirect_ABC.html, and 200 hits to redirect_XYZ.html, then you can be quite certain that 100 visitors clicked on the ad, and 200 people clicked on the ad. The addition of these simple redirects has not changed the experience of visitors to your site, but it has allowed you to verify the exact number of users who click on advertising, and to know which ad users clicked - so redirect pages are pretty useful!
The only question left to answer is, "How can I make a redirect page?" There are a variety of ways, but we have compiled a few of the easiest to get you started. If you are familiar with Web programming, you may want to adapt these samples to your site to make them more powerful. If you are a beginner to HTML, do not worry, this will be enough to get a basic redirect script in place.
HTML Redirect: This is probably the simplest type of redirect page. It really cannot be adapted to make it more powerful, but for a quick, straight-forward redirect script, the HTML redirect should do the trick.
JavaScript Redirect: JavaScript is a programming language that is understood by almost all browsers. The disadvantage of using a JavaScript redirect (as opposed to an HTML redirect, like the one above) is that some users with older Internet browsers may not be redirected, although this should be rare. The advantage of using JavaScript is that you can add additional JavaScript to make the script more functional. For instance, you could make a page that redirects some users to one site, and some users to another site. Here is a simple JavaScript redirect page that you can modify for your own purposes.

Advanced Redirects - ASP: The final example included is in yet a third language, Active Server Pages or ASP. This will only work on Microsoft IIS Web servers, but we wanted to include it as a launching point for users who may wish to use more complicated redirect scripts. This script is different from the others we have looked at in that the user (or the web designer) can specify to where the user is redirected, using a URL query. For instance, if you copy the following code into a file called "redirect.asp", and then placed it on a Microsoft Windows web server, then executing...


...would send you to a file called xyz.html, assuming such a file exists. This kind of redirect can have many uses depending on the situation, but this article does not cover this.

Was this article helpful?

Please tell us how we can make this article more useful.

Characters Remaining: 255