padams edited this page Jan 28, 2015 · 1 revision

Metrics are specialized objects within the OWA framework that are used to encapsulate the logic for producing analytic metrics like page views, "visits", or unique visitors. Metrics can be used by developers to produce data that will show in reports or accessible via the data export API.

Table of Contents

Creating a New Metric

To create a new metric you'll need to create a new owa_metric class.

For example the following class implements the pageView metric on OWA's main request table/entity:

class owa_pageViews extends owa_metric {

	function __construct() {
		$this->setLabel('Page Views');
		$this->setSelect(sprintf("count(distinct %s)", $this->getColumn()));
		return parent::__construct();

Metric / Entity Relationship

Metrics are tied to a single entity (and thus database table) within OWA so that metric calculations do not inadvertently create joins across OWA's fact tables. Therefor it is necessary to implement and register multiple implementations of a metric if you want OWA to calculate the metric from different database tables.

This is typically used to achieve metric different combinations as well as when creating resultSets from specialized summary tables.

Location of Metric Classes

Metric classes must be housed in their own files located within the metrics sub directory of the module that registers them. For example:


Registering a New Metric

Metric implementations are registered in module class constructors using the registerMetric module method. For example:

 $this->registerMetric('pageViews', 'base.pageViews');

This example will register an implementation of the pageViews metric. The second function argument is OWA file location short hand for using a metric class found in the base modules metric sub directory in a file called pageViews.php.

You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.
Press h to open a hovercard with more details.