Team LiB
Previous Section Next Section

Using Page Counters

As I stated earlier, page counters are a subfeature of site counters. They allow you to log the request of pages within a web site. Because the expected data volume could be very high, page counters are deactivated by default and have to be activated first through the configuration file web.config:

<siteCounters
    enabled="true"
    ...
>
    <pageCounters
        enabled="true"
        rowsPerDay="1"
        trackApplicationName="true"
        trackPageUrl="true"
        counterGroup="PageCounters"
        counterName=""
    >
        <pagesToCount>
            <add path="*"/>
        </pagesToCount>
    </pageCounters>
</siteCounters>

Afterward, all the hits on a page are logged in the counter group PageCounters — namely one line per day and per page, as shown in Figure 10-6.

Click To expand
Figure 10-6: Page counters log every hit on every page of your web site.

Alternatively, you can limit the logging to single pages or define certain areas with the help of wild cards:

        ...
        <pagesToCount>
            <clear />
            <add path="subdir/*.aspx"/>
        </pagesToCount>
    </pageCounters>
</siteCounters>

Internally, by the way, page counters work with the System.Web.PageCountersModule module. This HTTP module logs the hits within an event handling of HttpApplication.EndRequest and passes them to the Site Counter API.

Note 

Please be aware that only requests of files with the extension .aspx will be logged in the existing version. Web services or hits on files with an individual extension won't be part of the statistic.


Team LiB
Previous Section Next Section