1 vote

Counter for Page View and File Downloads (Optimized)

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:

  1. Table : ReflectionsUmbracoUtilitiesPageViewCounter
  2. Stored Procedure : ReflectionsUmbracoUtilitiesGetPageViewCount
  3. Stored Procedure : ReflectionsUmbracoUtilitiesSetPageViewCount
  4. Table : ReflectionsUmbracoUtilitiesFileDownloadCounter
  5. Stored Procedure : ReflectionsUmbracoUtilitiesGetFileDownloadCount
  6. Stored Procedure : ReflectionsUmbracoUtilitiesSetFileDownloadCount

Screenshots

Documentation

Source code

Package owner

Omar El Sergany

Omar El Sergany

Omar has 84 karma points

Package Compatibility

This package is compatible with the following versions as reported by community members who have downloaded this package:
Untested or doesn't work on Umbraco Cloud
Version 8.18.x (untested)

You must login before you can report on package compatibility.

Previously reported to work on versions: 7.15.x

Package Information

  • Package owner: Omar El Sergany
  • Created: 09/09/2019
  • Current version 2.1.0
  • .NET version 4.7.2
  • License MIT
  • Downloads on Our: 858