How to configure ContentMetrics

From EtherWiki
Revision as of 15:53, 13 June 2010 by Sstrader (talk | contribs) (Configuring the source web site)
Jump to: navigation, search

ContentMetrics is added to a web site by configuring a ContentMetrics (CM) server and then registering the source web site that will communicate with the CM server.

Configuring the ContentMetrics server

A ContentMetrics server (%CM-SERVER%) can be hosted on any web server that has MySQL 5+ and PHP 5+. Current available servers are:

The source web site must be registered with a user profile name (%PROFILE-NAME%) and host name (%HOST-NAME%).

Configuring the source web site

The following style sheet and two JavaScript file must be added to the <head> section of any page that will communication with the CM server:

<link rel="stylesheet" type="text/css" media="screen"
    href="%CM-SERVER%/style/cm.css" />
<script type="text/javascript"
    src="%CM-SERVER%/javascript/prototype-1.6.0/prototype.js"></script>
<script type="text/javascript"
    src="%CM-SERVER%/javascript/cm.js"></script>

With these entries added, any number of regions can be added to the page. Each region will track metrics for that region and display configurable results. The result will display wherever the script is placed on the page. Here is the basic format of the region script:

<script type="text/javascript"
    src="%CM-SERVER%/region_create.php?id=%PROFILE-NAME%&region=%REGION-ID%&actions=%ACTIONS%&metrics=%METRICS%">
</script>
An example of a region script displaying all metrics

The following values are required:

  • %CM-SERVER% and %PROFILE-NAME% - The CM server that will track the data under the profile registered on that server
  • %REGION-ID% - A unique value within the registered %HOST-NAME%
  • %ACTIONS% - A bit mask of allowable actions for this view of the reigon:
Value (position)Description
100 (1)Record each visit. Turn off to use the region only for displaying metrics and voting on the content.
010 (2)Allow visitors to up vote
001 (3)Allow visitors to down vote
  • %METRICS% - A bit mask of what recorded metrics should be displayed. For clarity, these are group into seven visit and vote metrics and four date/time metrics:
Value (position)Description
1000000 0000 (1)Display total visits
0100000 0000 (2)Display total unique visitors
0010000 0000 (3)Display total vote value (up votes - down votes)
0001000 0000 (4)Display total up votes
0000100 0000 (5)Display total down votes (as negative)
0000010 0000 (6)Display total visits for the current visitor
0000001 0000 (7)Display vote value for the current visitor
0000000 1000 (8)Display date and time of the first visit
0000000 0100 (9)Display date and time of the most recent visit
0000000 0010 (10)Display date and time of the first visit for the current visitor
0000000 0001 (11)Display date and time of the most recent visit for the current visitor

Here are some examples assuming the containing web page resides on a registered %HOST-NAME% registered under etheradmin on the CM server www.scottdstrader.com:

http://www.scottdstrader.com/cm/region_create.php?id=etheradmin&region=article-id-1024&actions=011&metrics=11111001100

This tracks metrics for the region article-id-1024. Names are unique identifiers on the host name and can be referenced across any number of pages or even multiple times within a page. For a blog, you may want to include a region script for an article in multiple places: the main page, the category page, and the article's permalink page.

The actions 011 enable voting but do not record a unique visit when the page is displayed. This allows you to display metrics in a summary listing page without recording the viewing of those metrics as an actual visit.