F2B1D91BBA3944049EC122FF204D531C
  • Internet
  • 04.10.2017
  • EN

LiveServer Page View Counter Setup

written by Javahand on Wed, 03/18/2009 - 00:15
 

SECTION A - WHY

Online business intelligence has come a long way and any kind of Web metrics tools can be obtained at little or no cost.

Nevertheless, most of these tools are designed for site administrators. Little or no convenience is there when one needs to organize and present contents on basis of the rich set of statistics these tools provide.

Even if a Web service API allows one to interact with such tools, the limitation on the granularity one can achieve with an API call or the performance overhead of making the call itself present some serious deterrents to a seamless incorporation.

This document shows you how easy and convenient it is to take advantage of LiveServer's out-of-the-box functionality to set up universal page hit counting; since the hit count persists in LiveServer, it is indexed and can be used by Verity Search to sort contents on basis of page views.

Such a handy feature can be implemented on a search result page where matching contents can be sorted on basis of popularity.
 

SECTION B - HOW

B.1 DEFINE THE HIT COUNTER AS A CONTENT ATTRIBUTE

The first step is to configure a universal content attribute designated to represent page views. In the example we are going to illustrate, such attribute is defined as "pageview".

Go to LiveServer server administration menu and select "Assign Content Attributes" under Connectors->Search Engines:


 

B.2 MAP THE HIT COUNTER AS AN INTEGER IN VERITY SEARCH

Once the configuration dialog opens, proceed to define the properties of "pageview":


 

Content attribute - the name we have decided to assign to the attribute we are defining, in this particular case, the hit counter.
Search engine field - the name under which this content attribute is stored in Verity Search Engine. It is not mandatory to have the same name as the content attribute. 
Search engine field type - Verity Search is capable of conducting SQL syntax complex search on contents deposited in LiveServer; however, this capacity is only enabled on content attributes that are mapped as search engine fields. All else is text based search.

In this particular case, we select Integer as the search engine type for "pageview" simply because we want to be able to use this attributes as a real numeric, not just a string literal that represents the numeric.

Once it is mapped as an Integer, we will be able to use SQL syntax on it when conducting search, such as > (greater than), <(less than), =(equal) or !=(not equal).note 1


Note 1. The SQL syntax listed here is for narrative purposes and do not represent the actual syntax required by LiveServer query dynaments. Please consult your LiveServer dynament menu for relevant information.


B.3 EMBED THE HIT COUNTER DYNAMENT IN PAGES

In all pages that require the hit counter, we will need to embed a simple dynament that increment the hit counter value and persist it in data base:


 

This simple dynament broken down and explained as follows:

<rde-dm:attribute mode="write" op="increase" attribute="content:pageview" value="1" />

mode - Whether the dynament is supposed to read or write the attribute value into the page's metadata.
op - How the value is written. In this particular case, the value is to increase.
value - By how much.
 

B.4 SEE THE COUNTING ACTION

Upon this point, we have defined the counting mechanism (the dynament) and its corresponding data field. Now you can fire up your browser, visit the page(or pages) that have the aforementioned dynament embedded.

Depending on how many times you've viewed (loaded ) a specific page, when you go into content administration and click on that page's "Attribute" tab, you will see the "pageview" value:


 

Please note the aforementioned dynament can be embedded from RedDot CMS page template; it does not have to be manually inserted on page instances in LiveServer.

To put the counter on the page itself, a simple dynament as follows will do it:

<div>This page has been viewed <rde-dm:attribute mode="read" attribute="content:pageview" tag="notag" /> times.</div>

In a query dynament, you can specify [sortedby="pageview" sortorder="desc"] to achieve search result sorting by content popularity.


Source: LiveServer Page View Counter Setup

© copyright 2009 by byteweaver [byte.weaver] - n, a digital craftsman