There isn't anything out-of-the-box to do this with Umbraco, you'll need to implement it yourself.
I generally use Google Analytics for page-views/stats ... I have rolled my own view-counter, but it's not the best example of what to do... for each page load I was incrementing a counter in a node/document's property. Which had to be republished to be used ... so each page-reload was a republish, not very good for performance! (I do not recommend doing this)
Thanks for the links. I will be considering the second link dont think having i will be using the Google Analytics since i need a counter for a Most Viewed Article in an Intranet System.
I assume you've added the View Count datatype to a document type, and have published a few documents based on that document type? If you refresh one of the published pages, it should update the count.
You should also be able to see the number of Views on the Document in the backend if you have it setup correctly...
Note that if you set a category in your View Counter datatype, you will need to specify that category in the ViewCounter:GetViews() method in XSLT as well. GetViews has 3 function signatures:
if you leave the category blank in the View Counter Datatype you can just use the first signature as you have in the XSLT example you posted. Otherwise you must use the second or third form. The increment parameter allows you to increment the viewcount at the same time (it's done prior to the data lookup) - by default this value is false.
You could call GetViews(number(@id), '', 1) in your xslt to increment the view counter for a page without specifying a category.
You don't have to attach the datatype to a document in order to use the view counter. Doing so however allows you to see the number of views a document has received. It also allows you to reset the view count. If you do use the datatype, make sure the category reflects whatever you use in the xslt library function
There is a sample Razor Script supplied with the package that you can use to embed in a document template. This is how I increment my view count on pages.
Yep, I just confirmed this and have uploaded a fix. Go download version 0.6.1 of the package. Note also that this bug only affects the GetViews method, all of the other library methods are not affected at all.
Am trying to achieve the same thing with media but somehow it returns "0". Just for information i have a macro xslt mediaPicker displaying all recents uploads.
But now clients would like to get the number of views for each Media item ,so added a new property in the Media Type with Type View Count.
Firstly, apologies for not getting back to you sooner, have been interstate for the better part of the past 3 weeks with limited internet access (doing my work using my iPhone tethered to my laptop with remote desktop to my server aint fun)
The package wasn't designed for use with media - it can be made to, but I need to know more about how you are displaying the media you are wanting to track...
Most Viewed Node
Hi All,
Is it possible to make display a list of "Most Viewed Node" in Umbraco With XSLT or Razor??
//fuji
Hi Fuji,
There isn't anything out-of-the-box to do this with Umbraco, you'll need to implement it yourself.
I generally use Google Analytics for page-views/stats ... I have rolled my own view-counter, but it's not the best example of what to do... for each page load I was incrementing a counter in a node/document's property. Which had to be republished to be used ... so each page-reload was a republish, not very good for performance! (I do not recommend doing this)
Quick google search found these:
http://stackoverflow.com/questions/6627673/umbraco-cms-how-to-make-a-hit-counter
http://refactored.com.au/blog/2011/11/14/introducing-the-umbraco-view-counter/
Cheers, Lee.
Ah ha, noticed that the second link, has a package available: Refactored's Content Views
Hi Lee,
Thanks for the links. I will be considering the second link dont think having i will be using the Google Analytics since i need a counter for a Most Viewed Article in an Intranet System.
//fuji
Hi Fuji,
The following xslt example will sort based on the number of views:
The key is the data-type="number" attribute on the xsl:sort element... It is missing from the example in the package.
Let me know how you go,
Rob.
Hi Robert,
I try the xslt but its not working though. Also i added the View Count Datatype to my Document Type but still the Count remains "0 View".
I instead change the xslt to
Just to get the number of count for the currentPage but still no output only NodeId displayed.
//fuji
Any thought what i might be doing wrong??
This is my output...
Node: 1497
Count: 0
Last Viewed:
Category:
hide Counter: 0
enable History: 0
Hi,
I assume you've added the View Count datatype to a document type, and have published a few documents based on that document type? If you refresh one of the published pages, it should update the count.
You should also be able to see the number of Views on the Document in the backend if you have it setup correctly...
Sitll nothing robert, even in my Backend i still have 0 views.
Here is how i proceeded. In my datatype View Count
Category: number
Hide View Count: no
Enable View History: no
Disable Counter Reset: no
and in document tpe with type alias "count" and type "view count". and finally my xslt
Note that if you set a category in your View Counter datatype, you will need to specify that category in the ViewCounter:GetViews() method in XSLT as well. GetViews has 3 function signatures:
GetViews(int nodeId)
if you leave the category blank in the View Counter Datatype you can just use the first signature as you have in the XSLT example you posted. Otherwise you must use the second or third form. The increment parameter allows you to increment the viewcount at the same time (it's done prior to the data lookup) - by default this value is false.
Hope this helps,
Rob.
Weird am still not getting anything....i left the datatype Category blank and use this in my xslt
is there something to set in the documentType alias?
It works when i change it to
Setting the dataType to View.
//fuji
Hi,
As you found, you will need to call one of the library methods that increments the view count. I actually had forgotten that myself, although it's discussed in the blog entry here - http://refactored.com.au/blog/2011/11/14/introducing-the-umbraco-view-counter/
A few things to note:
Hope this helps.
Rob.
One more thing - the project forums also discuss this topic - you may want to take a look there: http://our.umbraco.org/projects/website-utilities/refactored-content-views/developer-questions/26080-List-of-most-visited-pages
Hi,
For the time being i will leave the datatype in the document type so as to allow the admin to monitor and see the number of views for a node.
I will try the razor script as well, good to know both.
Thanks
//fuji
Just to point out when using this
GetViews(number(@id), '', 1)
it actually increments by 2 instead of 1
Hi Fuji,
Yep, I just confirmed this and have uploaded a fix. Go download version 0.6.1 of the package. Note also that this bug only affects the GetViews method, all of the other library methods are not affected at all.
Thanks,
Rob.
Hi Robert,
Am trying to achieve the same thing with media but somehow it returns "0". Just for information i have a macro xslt mediaPicker displaying all recents uploads.
But now clients would like to get the number of views for each Media item ,so added a new property in the Media Type with Type View Count.
Any suggestions why this is not working?
Thanks
Hi Fuji,
Firstly, apologies for not getting back to you sooner, have been interstate for the better part of the past 3 weeks with limited internet access (doing my work using my iPhone tethered to my laptop with remote desktop to my server aint fun)
The package wasn't designed for use with media - it can be made to, but I need to know more about how you are displaying the media you are wanting to track...
How can we find recently visited 3 pages in umbraco can any one help pls?
My bro. Thanks!. What is the Package?
Here is the link to the package
is working on a reply...