Umbraco Page View Counter (Optimized)
this package is a statistics counter for individual pages to display in front end.
it's the simplest way to show how many times the page has been visited.
Note: this is an optimized way to count the page views, it uses custom database table to store data.
It doesn't save and publish every time the page is requested, so you can use it without worrying about the performance in high traffic websites.
Follow these instructions:
1.Install the Package (Developer > Packages)
2.add the below code to the page template you need to count page views
@{
int nodeId = Umbraco.AssignedContentItem.Id;
string cookieName = String.Format("PageView_{0}", nodeId);
if (Session[cookieName] == null)
{
Reflections.UmbracoUtilities.PageViewCounter.SetPageViewCount(nodeId);
Session[cookieName] = 1;
}
}
3.add the below code in the place you need to display the counter in.
@Reflections.UmbracoUtilities.PageViewCounter.GetPageViewCount(Umbraco.AssignedContentItem.Id)
For File Download Counter
@{
var downloadableBrochure = Model.Value<IPublishedContent>("downloadfile");
int MediaId = downloadableBrochure.Id;
}
<a href="@(Reflections.UmbracoUtilities.FileDownloadCounter.FileDownloadCount(Umbraco.AssignedContentItem.Id,MediaId))" target="_blank" download>Download Brochure</a>
To get file download counter
@(Reflections.UmbracoUtilities.FileDownloadCounter.GetFileDownloadCount(Umbraco.AssignedContentItem.Id,MediaId))
Please Note if you will uninstall the package you need to delete the below from the database: