DotNet Development, SharePoint Customizing, Silverlight, MS Infrastructure and other tips and tricks

How to add a HIT COUNTER to a page

Posted by PANVEGA on June 22, 2009

In this post I wanna describe how to add a Hit Counter Component by using Microsoft Office SharePoint Designer.

Attention: this description below is just useful when you creat a new aspx page or prepare your MasterPage for example. If you try adding the Component to a Page Template, the Page instances refernce to the same central component. That mean the counter does not start from zero when you create a new page from a template. It goes on incrementing the counter from the first page you created. That means every page instance shows the same page or hit counter.

In my next post I gonna explain how to solve this problem.

Here are the steps to do (Refererences to this article)

Web Component

  1. Open the SP Designer first
  2. Start a new page. To do this in SharePoint Designer 2007, click the New Document button on the toolbar.
    Click the New Page button on the toolbar or justoOpen your site or your sites Master page to insert this component.
  3. In Page view at the bottom of the document window, click Design.
  4. Put the insertion point where you want to create the hit counter.
  5. On the Insert menu, click Web Component.
  6. Under Component type, click Hit Counter.
  7. Under Choose a counter style, double-click a hit counter style, and then click Finish.
  8. To set the counter to a specific number, click to select the Reset counter to check box, and then type the number.
  9. To display a fixed number of digits in the hit counter, click to select the Fixed number of digits check box, and then type the number.
    Hit Counter
  10. For example, to display the hit counter as “00#” instead of as a single or double digit, click to select the Fixed number of digits check box, and then type 3.
  11. You can even create your own Hit Counter. Use “Reset counter to” to reset the counter from a given number. To display fixed number of digits use “Fixed number of digits” property. Click on “Ok”, the hit counter will be inserted to your page. The below code will be inserted in your page to display the counter.
  12. Click OK.

Webbot Source

You can see the Hit Counter increments for each hit.

If you wanna use a custom picture to the following:

<!–webbot bot=”HitCounter” i-image=”1″ I-ResetValue=”0″
B-Reset=”TRUE” I-Digits=”0″ U-Custom=”bilder/zahlen.gif” –>

If you get the red “X” on a page you have to check your login and authentication again. Then it should works fine.

Here’s how a Hit Counter looks in hte HTML, except that it’s all on one line.

<!–webbot bot=”HitCounter” u-custom i-image=”4″ i-resetvalue=”0″ PREVIEW=”<strong>[Hit Counter]
</strong>” i-digits=”0″ startspan –><img src=”_vti_bin/fpcount.exe/?Page=hitcounter.htm|Image=4″
alt=”Hit Counter”><!–webbot bot=”HitCounter” i- checksum=”30622″ endspan –>

Another nice thing is for timestamps in your page. Just copy the code below:

<!–webbot bot=”Timestamp” S-Type”REGENERATED”  S-Format=”%m/%d/%Y %H:%M”–>

Good Luck!


2 Responses to “How to add a HIT COUNTER to a page”

  1. andyburns said

    Take care with this when using the Publishing Features of MOSS. Hits are counted per page layout, not per page.

    See here for details:

  2. […] […]

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: