Tridion UGC Blog Series: Manage Ratings/Likes

Submitting and Viewing UGC Ratings through a Web Page

Very Similar to Comments (Refer THIS post) UGC Ratings can also be managed through below two ways

  1. Using UGC Mark-ups
  2. Using Tridion UGC Web Service API

Submit and View UGC Ratings using UGC Markup

You can refer the ugc samples comes in the SDL Tridion 2013 installation disk for typical UGC markups for Submitting and Viewing ratings. A typical markup for submitting and viewing the already submitted ratings are as shown below – you can put this in your template building block or choose to create a User Control to be rendered at run time:

tcm:2-95-64 – TCM URI of the Page on which Ratings are submitted and displayed

<ugc:PostRating runat="server" ItemURI="tcm:2-95-64" PostParameter="ratingValuetcm:2-95-64"> 
 <ugc:ItemStats runat="server" ItemURI="tcm:2-95-64"> 
 Rating: <ugc:ContextVariable runat='server' Var='ugcItemStats.AverageRating'/> (<ugc:ContextVariable runat='server' Var='ugcItemStats.NumberOfRatings'/> ratings)<br/>
 <h3>Ratings post</h3> 
 <form method="post" id="ratingForm">
 <select name="ratingValuetcm:2-95-64" size="1">
 <option value="1">1</option>
 <option value="2">2</option>
 <option value="3">3</option>
 <option value="4">4</option>
 <option value="5" selected="true">5</option>
 <input type="submit" value="Rate!"/>

Submit and View UGC Ratings using Tridion UGC Web Service API

Instead of UGC markup, you can also use Tridion UGC Web Service to submit ratings and retrieving already submitted ratings by making web service calls.

For this, please get the Tridion.ContentDelivery.UGC.dll from the SDL Tridion installation disk and add a reference to it. In your code, add following using namespaces:

using Tridion.ContentDelivery.UGC.Web.Model;
using Tridion.ContentDelivery.UGC.WebService;

Then use following web service calls:

Retrieving Rating Information for a Page


This will return a ItemStats object which can be accessed to retrieve various statistical information for rating as below:

ItemStats.NumberOfRatings - Total Number of Rating
ItemStats.AverageRating - Average of the total Ratings

Post Ratings for a Page

WebServiceHelper.PostRating(PageUri, 5);

Based on your need, you can user either way of Retrieving and Submitting the Ratings information for a Page (or similarly for a content on a page).

NEXT – Tridion UGC Web Service API Cheatsheet

LATERManaging and Analyzing Comments/Rating from CME


Director at Content Bloom India having 12+ years of experience in Software Development Life Cycle using AGILE, Iterative and RUP approaches. Experience in following: - CMS packages: SDL Tridion, Adobe Experience Manager (AEM), Sitecore, Umbraco, Kentico, and Alfresco - Search Engines: SOLR, AWS Cloud Search, Elastic Search - .NET Technologies: .NET & .NET CE Framework, ASP.NET, ASP.NET MVC, WCF, WinForms - Mobile Development: Android Native App, Windows Mobile App - Database: MS-SQL Server, MySQL - Program Management: JIRA, MS-Project, Trello - Design Tools: MS-Visio, StarUML - Infrastructure: Linux, Windows Server, AWS Have decent knowledge about Core Java, Spring MVC Instrumental in Application Architecture, Designing (HLD & LLD), Coding and deployment .NET applications (Web, Desktop, Mobile). Experience in following domain: - Digital Media & eCommerce - Travel & Hospitality - Aviation Industry - Education - Insurance - Automation - Automobile - Railways Education: Bachelor Degree in Computer Engineering and Post Graduate Diploma in Business Administration with specialization in Marketing

Tagged with: , , ,
Posted in SDL Tridion

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: