Webmaster-Showcase.net WebHosting Counter/Stats System

How the Yahoo! Webhosing Counter works

Some HTML code must be on a page to allow the Yahoo! WebHosting counter/stats system to count and collect other statistics. Other HTML code is required to show the counter

Collecting the data

The counter does the counting by making a request to visit.webhosting.yahoo.com. Code like this

<!-- Counter/Statistics -->
<script language="JavaScript" src="http://us.js2.yimg.com/us.js.yimg.com/lib/smb/js/hosting/cp/js_source/whv2_001.js">
</script>
<script language="javascript">geovisit();
<noscript>
<img src="http://visit.webhosting.yahoo.com/visit.gif?1010787396" border=0 width=1 height=1>
</noscript>

is automatically appended to normal HTML files served by WebHosting servers. The statistics collected by the "visit.webhosting.yahoo.com" server may be viewed by the owner of the web site using http://webhosting.yahoo.com/stats

Showing the count

You can show how many hits a particular page has had by placing this code on the page:

<img src=http://visit.webhosting.yahoo.com/counter.gif alt="Counter"/>

If you want to control how the counter looks you need to use the WebHosting counter setup procedure.

How to use the WebHosting counter on PHP pages

The Yahoo! WebHosting servers only append the counter collection code to HTML files. For PHP files you must do it yourself!

Again, you must collect the statistics, then you may show a count

Collecting the data

To collect the data, you must place the code shown above somewhere in your PHP script. This may be done several ways:

  1. Write it as normal HTML, not within a php-tagged area.
  2. Output the HTML using PHP write.
  3. Place the counter code in a separate file and use the PHP include command
  4. Use the auto_append_file

The first two methods are obvious.

The third method requires a separate file, for example "footer.html" containing the visit server access code as shown here:

<!--counter--><br />
<script language="JavaScript" src="http://us.js2.yimg.com/us.js.yimg.com/lib/smb/js/hosting/cp/js_source/whv2_001.js>
</script><script language="javascript">geovisit();</script><noscript>
<img src="http://visit.webhosting.yahoo.com/visit.gif" border=0 width=1 height=1/></noscript>

This file is invoked somewhere in you PHP script using 'include("/footer.html")'

The fourth method is similar but you don't have to put the PHP include command in each PHP file; the footer file will automatically be appended. The WebHosting PHP implementation sets the "auto_append_file" name to be "common_footer.inc".

Showing the count

Showing the counter is the same as shown above.

This page has been viewed Counter times.

Of course the IMG SRC code may be in a plain HTML section of your PHP script or you may use the PHP write command to output it.

Don't forget, if you want to control how the counter looks, use the WebHosting Counter set-up procedure.

Home
Show Me How Feedback
Last updated: Tue Feb 12 16:53:54 2008