Rating content for anonymous users with Mavention Anonymous Rating


Allowing users to rate your content is a great way of capturing feedback. SharePoint 2010 ships with the rating capability, which unfortunately at this moment doesn’t support rating by anonymous users. And this is exactly where Mavention Anonymous Rating comes in. Find out how to allow anonymous visitors to rate your content with Mavention Anonymous Rating.

Feedback through rating

When creating a solution you can never be sure about its success. Capturing feedback from your audience is an important asset in measuring how helpful and meaningful your solution is to them. Capturing feedback can be done in many ways. You can ask your users to fill in surveys, you can ask them to provide comments or you can ask them to rate your content. Which one you choose depends on your requirements and audience.

Rating in SharePoint 2010

One of the new capabilities in SharePoint 2010 is content rating. Out of the box SharePoint 2010 provides you with the rating capability that allows users to rate content on the scale of 1 to 5.

Rating items in a List in SharePoint 2010 using the standard rating capability

After activating content rating a new Rating field is added to the List. Using that field users can rate the content. A timer job running in the background ensures that all ratings are captured and calculated in the background introducing as little as possible performance penalty to your environment.

And while the standard rating mechanism is a great way to find out more about your content, it has one serious flaw. At this moment it doesn’t support rating by anonymous users.

What is Mavention Anonymous Rating?

Mavention Anonymous Rating is a solution created especially to provide the content rating capability for anonymous users on Internet-facing websites built on the SharePoint 2010 platform. Similarly to the standard rating capability provided with SharePoint 2010, it can be activated per List which allows you to control which content should be available for anonymous rating within your website.

Upon the deployment of the SharePoint Package two new Features are installed. One scoped to the Web Application, which deploys the Timer Job responsible for calculating ratings, and one scoped to the Site Collection which installs all the assets and allows you to enable anonymous rating on your lists.

After you enable both Features, you can start configuring anonymous rating on your site. For this go to the Pages Library Setting of the specific site and in the General Settings section click the Anonymous rating settings option.

Anonymous rating option in the List Settings

To enable anonymous rating, in the Anonymous rating settings screen choose Yes (1) and click the OK (2) button.

Enabling anonymous rating on a List

After you do this, the rating columns will be added to the list and anonymous users will be able to rate your content. You can now start using rating.

Using Mavention Anonymous Rating

Mavention Anonymous Rating can be used in many different ways. Which one you choose depends on your requirements and the type of website you are working with.

Showing average rating

First of all there is the Rating Field Control that displays the current average rating of the current page. You can use it whenever you only want to display the rating without providing the ability to rate the content. The control uses the same User Experience as the standard SharePoint 2010 rating control. To use the Rating Field Control on your pages simply add the following code snippet to your Page Layout:

<%@ Register TagPrefix="Mavention" Namespace="Mavention.SharePoint.AnonymousRating.Controls" Assembly="Mavention.SharePoint.AnonymousRating, Version=1.0.0.0, Culture=neutral, PublicKeyToken=a43c589e76ba4e3d" %>
<Mavention:RatingFieldControl FieldName="mvAverageRating" runat="server"/>

Rating Field Control on a Publishing Page

The Rating Field Control can not only be used by you to display the average ratings to your visitors but is also used in List Forms so that content authors can see the rating as well. While they can see the average rating, the control prevents them from editing it.

Rating Field Control in the View Properties form

Rating content the basic way

The easiest way of using Mavention Anonymous Rating is with the Rating Basic Control.

Rating Basic Control on a Publishing Page

Comparable to the Rating Field Control, the Rating Basic Control should be added to the Page Layout of Publishing Pages that you would like your visitors to rate. The main difference with the Rating Field Control is that the Rating Basic Control allows your visitors to rate the content.

The Rating Basic Control displays the current average rating as star images. Visitors can rate content using a rating form.

Rating a Publishing Page using the Rating Basic Control

After submitting the rating, the page is reloaded and the form is hidden. As soon as the submitted rating has been calculated the new average rating will be displayed on the page.

Average Rating updated with the latest rating

Rating content the AJAX-y way

Depending on the requirements of your website, you might be using AJAX to provide richer User Experience. In such scenarios using the Rating AJAX Control might be a better choice.

The Rating AJAX Control enhances the Rating Basic Control with dynamic behavior. Instead of using radio buttons and postback to rate the page, it allows your visitors to click on the star images to submit their rating. This User Experience is very similar to the standard SharePoint 2010 rating.

Rating content using the Rating AJAX Control

After the user rates the page, an asynchronous call is made to the Anonymous Rating HTTP Handler and the rating is stored for processing by the Timer Job. At the same time the rating control becomes disabled so that the user cannot rate the same page multiple times.

Rating content using the Rating AJAX Control disabled after submitting a rating

Because it’s an Internet-facing website that we are talking about here, there are situations when the visitor has no JavaScript enabled. In such situations the Rating AJAX Control is rendered as the Rating Basic Control: the average rating is displayed as stars and users can rate the current page using the rating form.

Rating content on optimized sites

SharePoint 2010 is a platform for building web-based solutions. Because it’s a platform it’s up to you to tell it which components you want to load and which you don’t need. One way of optimizing Internet-facing websites built on the SharePoint 2010 platform is to exclude the form runat=”server” tag which minimizes the HTML markup generated by both SharePoint 2010 and ASP.NET and lowers the page’s footprint. Although this allows you to optimize your markup it requires you to build controls differently in order for them to work correctly.

If you’re working with an optimized site that doesn’t have the form runat=”server” tag the Rating Optimized Control is what you need to enrich your website with anonymous rating. This control is comparable to the Rating AJAX Control. The main difference is that it renders its own form tag which allows the visitors to submit the rating even when there is no form runat=”server” and with JavaScript disabled.

form tag rendered by the Optimized Rating Control

Rating specific pages

In all the previous scenarios we assumed that you would allow your users to rate all pages of the specific type by including the rating control in the Page Layout. But what if you wanted to allow them to rate specific pages only?

To support such scenarios all controls we have just discussed have been wrapped with Web Parts what allows you to cherry-pick which pages should support rating by adding the Rating Web Part of your choice to those specific pages.

AJAX Rating Web Part added to a Publishing Page

…and if we totally missed the boat…

Although we have put quite some effort in supporting different rating scenarios it might just happen that we don’t support yours. Does it mean Mavention Anonymous Rating isn’t for you?

Even if you can’t benefit from the standard rating controls, you can still use the Mavention Anonymous Rating API and provide your own rating UI. Depending on your requirements you can either call the HTTP Handler to submit ratings dynamically or you can communicate directly with the public API.

Configuration capabilities

Integrating custom components in Internet-facing websites isn’t as easy as you might think. While you can anticipate integrating in a standard SharePoint 2010 site, making a custom component an integral part of a custom User Experience of an Internet-facing website can become very challenging.

Configuring Mavention Anonymous Rating

To simplify integrating Mavention Anonymous Rating with Internet-facing websites, the component has some configuration capabilities built in. As you might have expected Mavention Anonymous Rating requires some JavaScript to support AJAX rating. To lower and standardize the development effort we used jQuery for that purpose. Both files form a dependency for the component. But what if you are already using jQuery in your own site? Using the configuration screen you can set for each dependency whether you want the control to load it itself or whether you have already included all dependencies in your own solution and the controls should assume that everything is already loaded. This applies not only to JavaScript but also to CSS so that you can style the rating control virtually any way you need.

After the rating

Mavention Anonymous Rating has been created particularly for anonymous users. One thing about anonymous users that makes it challenging for a rating component to work, is, that they are anonymous. Since you don’t have any information about the user it’s difficult to determine if he has rated the particular content already and if so to prevent him from rating it multiple times. Although there are many approaches of identifying anonymous users, each one of them has its pros and cons. Instead of deciding for you which one to use, Mavention Anonymous Rating gives you the ability to choose the mechanism that suits your needs the best yourself.

In its current version Mavention Anonymous Rating allows you to identify anonymous users either by cookie or by IP address. In the first case, the first time the user rates some content a cookie with a unique identifier is placed on his machine. Each time this user will come to a page that allows rating, a check will be made if the user has already rated this page or not. The downside of using cookies is, that as soon as the user clears his cookies, he can start rating your content all over again.

Another approach for identifying users is by their IP address. The first time the user rates some content, his IP address is stored. The next time he will visit a page that allows rating a check will be made if that specific IP address has already been used for rating content and therefore if the user should be allowed to rate the page. While it’s not that easy for users to change their IP address this approach might have undesired side effects especially if the majority of your users work at companies that have a single public IP address. In such scenarios only the first user is allowed to rate the content.

As you can see the choice is not easy and depends a lot on your requirements and the audience of your site. You can configure which approach you want to use using the Mavention Anonymous Rating configuration screen in Site Collection Setting.

Configuring the user identification method

The next step

As you can see Mavention Anonymous Rating is a complete solution that supports different scenarios. Although the initial requirement (allow anonymous users to rate content) sounds very easy, it isn’t, especially if you consider all the different challenges that integrating a custom rating component on an Internet-facing website introduces.

For this reason we have decided to release Mavention Anonymous Rating as a commercial product only. At this moment there is no free community version available. Don’t worry: it is not the beginning of a new trend. It’s just that particular solution that turned out to be that complex “just” to make it work.

I hope that I made you curious enough to consider using Mavention Anonymous Rating on your Internet-facing website built on the SharePoint 2010 platform.

Others found also helpful: