Have
you ever wondered how many people have visited your website? If you'd like to
keep track, you can put a counter on the front page or any other page you want
to guage. I decided to start simply and keep track of how many of my friends
had visited my website. Do you know what I discovered?...YOU DON'T HAVE TO BE
A COMPUTER GENIUS TO...Put a Counter on Your Website!!!
Here's
a step-by-step guide. ONE DISCLAIMER, I WILL BE DESCRIBING THE STEPS I TOOK
USING THE WEBHOSTING AND SOFTWARE SERVICES I HAVE CHOSEN. IF YOU HAVE DIFFERENT
BACK-END SUPPORT, YOU WILL HAVE TO ADJUST ACCORDINGLY.
My Tools:
- Windows 98
-
Web2010
as my hosting company, using UNIX
-
WS_FTPLE
(32-bit) for my file transfer protocol
-
Dreamweaver
as my web page designing software
-
TELNET
or SSH
program used to connect to the UNIX Shell on Web2010's servers so I can
create and modify directories and files on my site
-
PICO,
a simple text editor in TELNET
- REMEMBER...Files
should always be named in small letters not CAPS!
Summary:
Whenever someone types in the address of your website, your web server
checks for a file named .htaccess. (.htaccess has many functions other than
triggering a counter, such as enabling password protection) before displaying
the page. If the .htaccess file is present on your root directory AND contains
the right code, your server will count the number of people that visit your
website. The page logs are tracked in a ".counter" file.
Here's what I needed to do:
a)
Create a new file called ".counter" (note: the "." before
counter) and place it in my root directory (i.e., the directory that shows
up when I first connect to my web hosting service, Web2010.)
b) Edit the existing ".htaccess" file in that same root directory
c) Edit the html code of my "index.html" file
Step-by-Step:
- Run TELNET
Program to Create and Modify Files Directly to the Server. Windows 98
comes with a basic TELENT Program. I went to START, then clicked on RUN and
typed telnet mydomain.com. (Hit ENTER) What popped up was a white screen
in the DOS style. At the LOGIN prompt, I typed in my Web2010 username and
at the PASSWORD prompt, I typed in my Web2010 password. (Hit ENTER). IF You
use SSH instead then do the following:
- Download
Free version of SSH and connect to server. If you don't already have SSH,
you can either go to www.ssh.com to purchase the protocol or go to www.tucows.com
to download a basic version of SSH as freeware; it's called PUTTY. Once SSH
is downloaded in your "my download files" on your "c"
drive (or to whatever location you chose to download), create a shortcut a
put the SSH Putty icon (of two computers and a lightening bolt) on your desktop.
Click on the icon and in the Putty configuration box that pops up, you'll
see "seesion" under category on the left column. Click that and
on the right where it says "Basic Options for your Putty Session"
specify your connection by typing in your domain name (including the ".com",
but no "www") and under protocol click "SSH." Then under
"Saved Sessions" type your domain name again in the white blank
line and click "save" to save the session. Now you can click "open"
and a black screen comes up. You are connected! If the black screen does not
pop up or is "inactive", go back to your Putty Configuration Box
and in the lower left column under "Connection", highlight SSH.
Then, in the right column under "Preferred SSH Protocol" click Version
2 and hit "Open." Then reinput the domain.
- Create .Counter
File. The screen displayed the path to my domain (or root directory) on
Web2010's servers... www26:/mnt/web/guide/yourdomain#. On the same
line I typed touch .counter (note the space before ".counter).
This created a ".counter" file on my root directory. (hit ENTER.)
The new ".counter" file I created was empty. It acts as the count
log and records the current count in binary form as web daemon writes to it
with each hit.
- Owenership
and Permissions. The new ".counter" file needed to be owned
by my username with permissions set at 666 to work properly. To change the
permissions on the ".counter" file with TELNET, I typed the following
chmod 666 .counter (hit ENTER). To change ownership at the command
line, I typed the following chown username .counter (Note: substitute
your actual Web2010 username and don't forget the spaces!) (hit ENTER)
- Create or
Edit .htaccess File. Then I had to edit the existing ".htacess"
file on my root directory. At the path directory prompt (i.e., www26:/mnt/web/guide/yourdomain#)
I typed pico .htaccess (note: the space before ".htaccess").
This either creates a ".htaccess" file on your root directory if
you don't already have one or, in my case, it opened the already existing
".htaccess" file on my root directory. On the blank white PICO screen
I typed the following: Counterfile /mnt/web/guide/yourdomain/.counter (Note:
space after "Counterfile", but no space before .counter. It will
look like this Counterfile /mnt/web/guide/mhwebcreations/.counter).
If you already have code inside your ".htaccess" file then you'll
have to scroll down to find room or hit the return key to make room. My ".htacess"
file was empty. IMPORTANT: there are other ways to accomplish putting code
in your ".htaccess" file. For example, you could have used Notepad
and saved the document as text and FTP'ed it to your server. I just think
the TELNET-PICO combo is the easiest. Next, I saved the new ".htaccess"
file in PICO by hitting CTRL X and responding yes or y to the "save
modified buffer prompt." Remember, when you use TELNET, you automatically
have saved directly to the server.
- Check.
At this point, I wanted to check my root directory to make sure I had created
a ".counter" file that was empty and a ".htaccess" file
that had the above-described one line of code. To check my work, I opened
my FTP program by going to START, then PROGRAMS and clicking on WS_FTP. Once
I connected to my FTP program by connecting with my Web2010 username and password,
my root directory popped up. The screen was split showing the contents of
my computer on the left and the contents of my domain on the right. I refreshed
the screen by clicking the REFRESH button and saw both the ".counter"
and ".htaccess" files. I was halfway there!
- Edit index.html
page. Now, I had to add the actual counter code to my front page or "index.html"
file. I opened DREAMWEAVER, my web design software and opened the file called
"index." I added the following code to bottom of the page where
I wanted the counter to appear: <img src="/server-cntr?face=default">
(Note: the space after "img"). In fact, you can add this code
to any web page in any subdirectory and it will count hits on that page for
you.
- Check.
Before modifying the counter's graphical look, I first tested what I'd done.
I saved the "index.html" file in Dreamweaver and then FTP'ed the
"index.html" to the "www" directory of my domain. I opened
mydomain.com and pulled up the first page a few times to make sure the counter
was counting--it was! IMPORTANT: If the counter does not work, you should
check the ownership and permissions of the new ".counter" file.
Or check the line of script you added to the ".htaccess" file to
see that you substituted yourdomainname prefix in the line of text.
- Establishing
or Resetting Account. If you ever want to set the number on your counter
to something different from what appears (you know...to add a few hundred
hits to make yourself look popular!), you must TELNET your domain's root directory
again, telnet yourdomain.com. At the command line...www26:/mnt/web/guide/yourdomain#,
type: countctl.pl -s/index.html (Note: space before "-s")
(or the name of the homepage if not index.html) (hit ENTER.). You will be
prompted for a count number, enter up to 10 digits and hit ENTER. Refresh
you homepage and the new count should be displayed.
- Modifying
the Counter Display. Web2010 provides cgi script on each server that displays
html code with examples of different fonts etc. that I could use to cut and
paste on my page. I had to know the server where my website is located. For
example, www26.hostcentric.com. To see the counter choices displayed in a browser,
I used the URL http://www26.hostcentric.com/cgi-bin/show-digits.cgi. I
picked a style I liked and substituted the available html code on my index.html
page.
- Checking
Usage Logs. Web2010 provides the ability to check usage logs by opening
a browser and typing in http://yourdomain.com/logs/usage.html.
Copyright
© 2000-2001 Marlene Hollander. All rights reserved.