How to Make a Hit Counter in Dreamweaver
Because Dreamwaver makes it so easy to work with HTML code and scripts, even if you're a novice Web designer, adding a hit counter to your Web page is not difficult to do. There are a couple ways to make a hit counter. The easiest way is to get code for a free hit counter tool from your Web host and paste it onto your Web page. A second way is to create a PHP Web page and use a PHP script. The PHP method is a little more complicated, but you don't have to be a programmer to get it to work.
Instructions
-
Use Hit Counter Code From a Web Host
- 1
- 2
-
-
3
Click the button to create a new hit counter. You will be prompted to enter a name for the counter and provide the URL of the page you want to add the counter to.
- 4
- 5
-
6
Open Dreamweaver and open the Web page you want to add the hit counter to.
-
7
View the HTML code for your page by clicking the "CODE" button at the top of the window, then click at the location where you want the counter to appear. Usually counters are placed at the bottom of the page above the closing "BODY" tag.
- 8
Use a Free PHP Script
-
9
Use your Web browser to download a free PHP hit counter script from the Internet, such as the one at phpjunkyard.com (see Resources).
- 10
-
11
Place the PHP script and any files that came with it in this folder and read the instructions that come with the script for any special customization steps you need to take. Sometimes this information is on the Web page before you download, or it's a "readme" file included in the download.
- 12
-
13
Make any necessary changes to the PHP code following the programmer's instructions. Save and close the file.
-
14
Open the Web page you want to add the counter to and save it with the extension .php instead of htm or .html. To run PHP on your page, you need this file extension or the commands will be ignored. View the HTML code on this file.
-
15
Click at the location where you want the hit counter to appear (anywhere above the closing "BODY" tag), and paste in a PHP call to the hit counter file according to the instructions that came with your script. The code would look something like: <script language="Javascript" src="http://www.YOUR_DOMAIN.com/counter/gcount.php"><!--//--></script>.
-
16
Add a link back to the programmer's website under the counter (it's the considerate thing to do if you're using someone else's script for free), save changes to the file, then upload the php Web page and the counter folder to your Web server.
-
17
View the files on your Web server in Dreamweaver by selecting "Remote Site" from the top of the site files box on the right. If the instructions for your hit counter script say to change file permissions on any of the script files, right-click the file name and choose "Set Permissions" from the pop-up menu.
-
18
Make the changes to the "Set Permissions" screen and click "OK."
-
19
Return to "Local View" in your site files list and double-check the Web page that will have the hit counter to make sure you have the PHP command correct, then save, upload the file to the server and use your Web browser to view the page and test the hit counter.
Tips & Warnings
There are free hit counter service companies that offer code to copy and paste to your Web pages (like the Web-hosting example above). However, if the company goes out of business, the service will end. Because Web-hosting companies offer many services (not just hit counters), they tend to stay in business longer. You can also use a Perl CGI script for a hit counter. They work similarly to the PHP script mentioned here, and are free to download on the Internet.
Free hit counters from Web hosts may include graphics advertising the host company, but that's a small concession for something you're getting for free. Using a PHP hit counter will only work if your Web server has PHP installed. Most Web-hosting companies do, but Internet service providers that give you a free Web account as part of your connection package may not. When using the PHP script, you may need to update some links on your site since the name of your Web page will change when you add the .php extension to the file name.