I need to make a hit counter for Umbraco CMS. is there a way to do it? I would like to track popular articles and display them on the homepage.
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You will have to implement this yourself, this doesn’t come out of the box. Here’s how you could go about it:
First of all you need to know what you want to be counting: The number of times an url is requested? Or he number of times a node is viewed (the same node may be available under several url’s)? Hits or visits, should the counter go up if a user reloads a page?
For the actual implementation, you’ll need three parts:
1. The client request
Whenever a page is viewed which is supposed to be tracked, you’ll need to trigger a request to the server which allows you to increment counter for that page.
There are several ways to achieve that, I recommend to do this by including a picture request (1px transparent gif).
For example:
4882 is the node id of the article page and is different on every article page.
You should probably include the code which generates the url on the master page (template).
2. The server-side handler
On the server side, you’ll need a handler which responds to the picture request. A HttpHandler is perfect for this job. You can create it in a separate project, drop the dll in the bin folder and add the necessary web.config settings.
The handler has to do the following:
HTTP_REFERRERheader of the request, or by using the information in the url (like the node id in the url of the image as in my example above).3. Displaying the most popular links
In order to display the top articles on a page, you’ll need an Umbraco user control which queries the table in the database and displays the most popular links.