Saturday, May 1, 1999

An easy way to build your own simple, text-based Domino hit counter

WEB DEVELOPER STEP-BY-STEP

By Frank Cseh

Web page hit counters are popular; it doesn't matter in how many flavors they appear. In March, DominoPower ran an article about how to create a graphical hit counter (graphic images of the numbers would change). In this article, I'm going to show how to write a simple text-based counter.

It's valid for Domino based Web sites, as well. The best counter product is the nicest looking one and/or the simplest one to implement. I tend to go for the easy to create, simple hit counter.

I've seen solutions offered for Domino counters on the Web, both free and commercial. I just didn't have the urge to implement them on my internal Web sites. I needed a simple solution. Lately I've worked a lot with profile-form based documents, a really great feature in Notes. Profile documents are not created from the Create menu, do not appear in any views, and are not included in the document count for a database. A simple mind (Ok, it was me) would say that if I had a "server-side" environment variable and I could increment it when the user enters the Web site, I would then have a hit counter. That is what I created with the help of profile documents.

My hit counter was conceived to increment a field value of a profile document on WebQueryOpen event. That event is triggered when the visitor is entering the web site.

I think my Domino hit counter is simple to understand and implement and, I hope, well explained here.

Getting Started

To create a hit counter, you need a customizable Navigator in your Domino database.

Let's call the navigator MainNavigator for example. The form $$NavigatorTemplate for MainNavigator is where your navigator is embedded and is also where your counter will appear.

You also need a form with two fields for the profile document creation. Two agents are also needed: one is to create the profile document, and one to increment the counter.

Next, I will show the process of the counter creation step by step. Each step is illustrated with appropriate screen shots.

Step 1: Create the counter form

Start with the profile form. Create a new form and name it, for example: TheCounterForm, as shown in Figure A. On the form, create an editable text field and name it, for example: TheCounter. Also create a computed-when-composed text field, and name it: $PublicAccess.

FIGURE A

Create the counter form

For the computation formula enter: 1 (i.e., decimal number one).

There is still a bit more work you need to do before you can save the new form. Right click on the form and select Form Properties. Select the security tab (the key symbol), and select the Available to Public Access Users checkbox, as shown in Figure B. In the form properties you should also deselect Include in Menu checkbox. Now you can save the form .